Count Odd Numbers in an Interval Range

Easy

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 = 7
Output:3
Explanation:

Odd numbers: 3, 5, 7.

Input:low = 1, high = 1
Output:1
Explanation:

When low equals high and the number is odd, there is exactly 1 odd number in the range: 1.

Input:low = 4, high = 8
Output:2
Explanation:

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

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!