#906

Super Palindromes

master · 1775 · lc hard +32 · verified · 39.8% accepted · 376 likes · top 19%

Description

A positive integer qualifies as a super-palindrome when it is both a palindrome and the square of another palindrome. Given string representations of bounds left and right, return the count of super-palindromes in the inclusive range [left, right].

Example 1:

Input: left = "4", right = "1000"
Output: 4
Explanation: 4, 9, 121, and 484 are superpalindromes.
Note that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrome.

Example 2:

Input: left = "1", right = "2"
Output: 1

Code

1
2
3