Difficulty
Easy
Language
Python
Solution 1 - Count Odds via Prefix
Odds in [low,high] = odds(0..high) - odds(0..low-1).
""" 1523.1 - Count Odd Numbers in an Interval Range - Solution 1 - Prefix Count """
class Solution:
def countOdds(self, low: int, high: int) -> int:
return (high + 1)//2 - low//2