URL: https://leetcode.com/problems/count-symmetric-integers/ Signed-off-by: Matej Focko <me@mfocko.xyz>
19 lines
515 B
C#
19 lines
515 B
C#
public class Solution {
|
|
public int CountSymmetricIntegers(int low, int high) {
|
|
var count = 0;
|
|
|
|
for (var x = low; x <= high; ++x) {
|
|
if (x < 100 && x % 11 == 0) {
|
|
++count;
|
|
} else if (1000 <= x && x < 10000) {
|
|
var left = x / 1000 + (x % 1000) / 100;
|
|
var right = (x % 100) / 10 + x % 10;
|
|
if (left == right) {
|
|
++count;
|
|
}
|
|
}
|
|
}
|
|
|
|
return count;
|
|
}
|
|
}
|