1523. Count Odd Numbers in an Interval Range Easy
1/**
2 * [1523] Count Odd Numbers in an Interval Range
3 *
4 * Given two non-negative integers low and <font face="monospace">high</font>. Return the count of odd numbers between low and <font face="monospace">high</font> (inclusive).
5 *
6 *
7 * Example 1:
8 *
9 *
10 * Input: low = 3, high = 7
11 * Output: 3
12 * Explanation: The odd numbers between 3 and 7 are [3,5,7].
13 *
14 * Example 2:
15 *
16 *
17 * Input: low = 8, high = 10
18 * Output: 1
19 * Explanation: The odd numbers between 8 and 10 are [9].
20 *
21 *
22 * Constraints:
23 *
24 *
25 * 0 <= low <= high <= 10^9
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/
31// discuss: https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn count_odds(low: i32, high: i32) -> i32 {
37 0
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_1523() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.