Class Solution
-
- All Implemented Interfaces:
public final class Solution2843 - Count Symmetric Integers.
Easy
You are given two positive integers
lowandhigh.An integer
xconsisting of2 * ndigits is symmetric if the sum of the firstndigits ofxis equal to the sum of the lastndigits ofx. Numbers with an odd number of digits are never symmetric.Return the number of symmetric integers in the range
[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.
Constraints:
<code>1 <= low <= high <= 10<sup>4</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegercountSymmetricIntegers(Integer low, Integer high)-
-
Method Detail
-
countSymmetricIntegers
final Integer countSymmetricIntegers(Integer low, Integer high)
-
-
-
-