Count Odd Numbers in an Interval Range

Problem

Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive).

Example 1:

Input: low = 3, high = 7
Output: 3
Explanation: The odd numbers between 3 and 7 are [3,5,7].

Example 2:

Input: low = 8, high = 10
Output: 1
Explanation: The odd numbers between 8 and 10 are [9].

Constraints:

  • 0 <= low <= high <= 10^9

Solution

Recent posts from blogs that I like

Brushstrokes: Paul Signac

Initially he applied coarser dots on areas of more even colour, used simultaneous colour contrast, then his blobs grew to become patches of paint resembling the tesserae of mosaics.

via The Eclectic Light Company

Conceptual integrity and counting lines of code

via Simon Willison

Good writing is obvious, not original

When you write, you should try to say things that are obviously true, and spend very little time worrying about whether you’re being original. Ironically, this is the best way to do truly original writing.

Every important idea has been discussed already. I learned this in grad school for philosophy1...

via Sean Goedecke