Easy+ ยท pattern reuse

Palindrome Number

121 reads the same both ways; 123 doesn't. The insight: a palindrome equals its own reversal โ€” so reuse the previous problem's pattern and compare.

Problem

Input: one integer n (0 โ‰ค n โ‰ค 10โน).

Output: Yes if n is a palindrome, No otherwise.

Sample:

InputOutput
121Yes
10No

Your solution

Program.cs โ€” your solution
Custom input for "Run my input"

Judging runs entirely in your browser against hidden tests. Your code is saved locally as you type. Ctrl+Enter judges.

Stuck? Hints

Hint 1 โ€” keep the original

Reversing destroys n. Copy it first: int orig = n;, then compare rev == orig.

Hint 2 โ€” don't reach for strings

The string version (s == reversed) works too, but the integer pattern generalizes to interview follow-ups like "reverse only the second half".

Solution (try first!)
int n = int.Parse(Console.ReadLine());
int orig = n, rev = 0;
while (n > 0) { rev = rev * 10 + n % 10; n = n / 10; }
Console.WriteLine(rev == orig ? "Yes" : "No");

Pattern reuse is the real skill here: reverse + compare. Next: Factorial.