Super Palindromes

Let's say a positive integer is a super-palindrome if it is a palindrome, and it is also the square of a palindrome.

Given two positive integers left and right represented as strings, return the number of super-palindromes integers in the inclusive range [left, right].

Example 1
Inputleft = "4", right = "1000"
Output4
4, 9, 121, and 484 are superpalindromes; 676 is not because although 26 * 26 = 676, 26 is not a palindrome.
Example 2
Inputleft = "1", right = "2"
Output1
The only super-palindrome in the range [1, 2] is 1.

Constraints

  • 1 <= left.length, right.length <= 18
  • left and right consist of only digits.
  • left and right cannot have leading zeros.
  • left and right represent integers in the range [1, 10^18 - 1].
  • left is less than or equal to right.

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