Mid/SeniorEnumerationMath

Sum of Number and Its Reverse

Given a non-negative integer num, return true if num can be expressed as the sum of any non-negative integer and its reverse, or false otherwise.

When a number is reversed, it may have leading zeros.

Example 1
Inputnum = 443
Outputtrue
172 + 271 = 443, so the number can be expressed as a non-negative integer plus its reverse.
Example 2
Inputnum = 63
Outputfalse
63 cannot be expressed as the sum of a non-negative integer and its reverse.

Constraints

  • 0 <= num <= 10^5

Asked at 1 companies

Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, what to keep, what's wrong, and the complexity of your solution.

Sign in to evaluate