2180. Count Integers With Even Digit Sum Easy

@problem@discussion
#Math#Simulation



1/**
2 * [2180] Count Integers With Even Digit Sum
3 *
4 * Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even.
5 * The digit sum of a positive integer is the sum of all its digits.
6 *  
7 * Example 1:
8 * 
9 * Input: num = 4
10 * Output: 2
11 * Explanation:
12 * The only integers less than or equal to 4 whose digit sums are even are 2 and 4.    
13 * 
14 * Example 2:
15 * 
16 * Input: num = 30
17 * Output: 14
18 * Explanation:
19 * The 14 integers less than or equal to 30 whose digit sums are even are
20 * 2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22, 24, 26, and 28.
21 * 
22 *  
23 * Constraints:
24 * 
25 * 	1 <= num <= 1000
26 * 
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/count-integers-with-even-digit-sum/
31// discuss: https://leetcode.com/problems/count-integers-with-even-digit-sum/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36    pub fn count_even(num: 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_2180() {
49    }
50}
51


Back
© 2025 bowen.ge All Rights Reserved.