cs: add «2843. Count Symmetric Integers»

URL:	https://leetcode.com/problems/count-symmetric-integers/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2025-04-11 09:45:36 +02:00
parent e69372dbef
commit aab8e6466e
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,19 @@
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;
}
}