2843. Count Symmetric Integers Easy

@problem@discussion
#Math#Enumeration



1/**
2 * [2843]   Count Symmetric Integers
3 *
4 * You are given two positive integers low and high.
5 * An integer x consisting of 2 * n digits is symmetric if the sum of the first n digits of x is equal to the sum of the last n digits of x. Numbers with an odd number of digits are never symmetric.
6 * Return the number of symmetric integers in the range [low, high].
7 *  
8 * <strong class="example">Example 1:
9 * 
10 * Input: low = 1, high = 100
11 * Output: 9
12 * Explanation: There are 9 symmetric integers between 1 and 100: 11, 22, 33, 44, 55, 66, 77, 88, and 99.
13 * 
14 * <strong class="example">Example 2:
15 * 
16 * Input: low = 1200, high = 1230
17 * Output: 4
18 * Explanation: There are 4 symmetric integers between 1200 and 1230: 1203, 1212, 1221, and 1230.
19 * 
20 *  
21 * Constraints:
22 * 
23 * 	1 <= low <= high <= 10^4
24 * 
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/count-symmetric-integers/
29// discuss: https://leetcode.com/problems/count-symmetric-integers/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34    pub fn count_symmetric_integers(low: i32, high: i32) -> i32 {
35        0
36    }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_2843() {
47    }
48}
49


Back
© 2025 bowen.ge All Rights Reserved.