Description
Given two non-negative integers low and high, return the count of odd numbers between low and high (inclusive).
Examples
Input:
low = 3, high = 7Output:
3Explanation:
Formula: (high+1)/2 - low/2 gives count of odds. For range [3,7]: (7+1)/2 - 3/2 = 4 - 1 = 3. The odd numbers are 3, 5, 7.
Input:
low = 1, high = 1Output:
1Explanation:
When low equals high and the number is odd, there is exactly 1 odd number in the range: 1.
Input:
low = 4, high = 8Output:
2Explanation:
The odd numbers in the range [4, 8] are 5 and 7. Even though both endpoints are even, there are 2 odd numbers between them.
Constraints
- •
0 ≤ low ≤ high ≤ 10^9