A desert highway has a concrete marker post planted at every integer mile, numbered consecutively starting from 0. A ranger crew logs the two marker numbers that bound the stretch they just inspected, and every marker bearing an odd number needs its paint refreshed before the next storm season. Given the boundary markers low and high of an inspected stretch (with low <= high), report how many markers numbered with an odd integer fall within [low, high], counting both endpoints.
A single line containing two integers low and high separated by a space.
A single integer: the count of odd-numbered markers in the inclusive range [low, high].
low and high are.Example 1
Input
3 7
Expected
3
Explanation
The markers in [3,7] are 3,4,5,6,7. Among these, 3, 5, and 7 are odd, giving a count of 3.
Example 2
Input
8 10
Expected
1
Explanation
The markers in [8,10] are 8,9,10. Only 9 is odd, giving a count of 1.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →