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

A painted weekend in Egypt 1

From the Book of the Dead, funerary portraits in encaustics, to imagined scenes in biblical times. Then seen by those who visited, from 1842 onwards.

via The Eclectic Light Company

Elegance and intelligence are anticorrelated

Elegance and intelligence can have a surprisingly negative correlation. Intelligent people sometimes produce inelegant solutions because they’re capable of rapidly brute-forcing problems. If I had to remember a hundred names, I would spend time coming up with clever mnemonics. John von Neumann would...

via Sean Goedecke

important green flags in other humans

more best practices

via bookbear express