#1523
Easy Algorithms Count odd numbers in an interval range
Math
54.4% acceptance
Feb 25, 2026
3118
181
Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive).
Solution
Rust
Time O(1)
Space O(1)
impl Solution {
pub fn count_odds(low: i32, high: i32) -> i32 {
(high + 1) / 2 - low / 2
}
}