From aab8e6466ebec62e7451e9c85cd387fe0e0465c8 Mon Sep 17 00:00:00 2001 From: Matej Focko <me@mfocko.xyz> Date: Fri, 11 Apr 2025 09:45:36 +0200 Subject: [PATCH] =?UTF-8?q?cs:=20add=20=C2=AB2843.=20Count=20Symmetric=20I?= =?UTF-8?q?ntegers=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit URL: https://leetcode.com/problems/count-symmetric-integers/ Signed-off-by: Matej Focko <me@mfocko.xyz> --- cs/count-symmetric-integers.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cs/count-symmetric-integers.cs diff --git a/cs/count-symmetric-integers.cs b/cs/count-symmetric-integers.cs new file mode 100644 index 0000000..e0db2bb --- /dev/null +++ b/cs/count-symmetric-integers.cs @@ -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; + } +}