Count Odd Numbers in an Interval Range

Easy

Company Tags

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

Example 1:

Input: low = 2, high = 9

Output: 4

Explanation: The odd numbers between 2 and 9 are [3,5,7,9].

Example 2:

Input: low = 9, high = 11

Output: 2

Explanation: The odd numbers between 9 and 11 are [9,11].

Example 2:

Input: low = 1, high = 1

Output: 1

Constraints:

  • 0 <= low <= high <= 1,000,000,000


Company Tags

Please upgrade to NeetCode Pro to view company tags.

low =

high =