Back to problems Sign in to unlock
Leetcode
Easy
Math
Arrays
Count Odd Numbers In An Interval Range
Count how many odd integers lie in the inclusive range [low, high].
Acceptance 100%
Problem Statement
Problem
Given two integers low and high, count how many odd numbers are in the inclusive interval [low, high].
An integer is odd if it is not divisible by 2.
Return the count of odd integers between low and high, including both endpoints.
Input Format
- Two integers
lowandhighdescribing an inclusive range. lowmay be less than, equal to, or greater thanhighin generalized practice settings; assume valid interval ordering unless stated otherwise.
Output Format
- Return a single integer: the number of odd integers in
[low, high].
Constraints
- The range endpoints are integers.
- Use an approach that runs in constant time.
- In standard interview settings,
low <= high.
Examples
Sample cases returned by the problem API.
Example 1
Input
low = 3, high = 7
Output
3
Explanation
The odd numbers are 3, 5, and 7.
Example 2
Input
low = 8, high = 10
Output
1
Explanation
The only odd number in the range is 9.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.