Ctrl K

A Number Plus Its Mirror

Medium
The mirror of a non-negative number is the number written with the same digits in reverse order; leading zeros after the flip are dropped (the mirror of 340 is 43). Given a non-negative integer n, return True if there is a non-negative integer k such that k plus the mirror of k equals n, and False otherwise.
Example 1
n=605 → True

352 + 253 = 605, so it works.

Example 2
n=25 → False

No number from 0 to 25 plus its mirror gives 25.

Example 3
n=110 → True

100 + 001 = 101 does not fit, but 55 + 55 = 110.

Constraints
  • 0 ≤ n ≤ 10⁵
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPrimes Below a Bound MediumShuffle the Digits Into a Power of Two MediumSums of Two Powers MediumA Multiple Spelled With Two Digits MediumMicrowave Keypad Effort Medium
loading Python…
Input
n=605
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 162 tests on the server, hidden ones included.