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:
The odd numbers in range [3,7] are 3, 5, and 7. Formula: (high+1)/2 - low/2 = 4 - 1 = 3.
Input:
low = 1, high = 1Output:
1Explanation:
When low equals high and the number is odd, there is exactly 1 odd number in the range.
Input:
low = 10, high = 20Output:
5Explanation:
The odd numbers in [10,20] are 11, 13, 15, 17, and 19, so the exact output is 5.
Constraints
- •
0 ≤ low ≤ high ≤ 10⁹