#2843
Count Symmetric Integers
newbie · 150 · lc easy +14 · verified · 83.1% accepted · 649 likes · top 95%
Description
Two positive integers low and high are given.
An even-digit integer x with 2 * n digits is symmetric if the sum of its first n digits equals the sum of its last n digits. Odd-length integers are never symmetric.
Return the count of symmetric integers in [low, high].
Example 1:
Input: low = 1, high = 100
Output: 9
Explanation: There are 9 symmetric integers between 1 and 100: 11, 22, 33, 44, 55, 66, 77, 88, and 99.
Example 2:
Input: low = 1200, high = 1230
Output: 4
Explanation: There are 4 symmetric integers between 1200 and 1230: 1203, 1212, 1221, and 1230.
Code
1
2
3