LeetCode 906, Hard. Topics: Math, String, Enumeration. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 33 parametrized pytest cases, and a playground notebook:
Problem
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 <code>left</code> and <code>right</code> represented as strings, return <em>the number of <strong>super-palindromes</strong> integers in the inclusive range</em> <code>[left, right]</code>.
Examples
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<sup>18</sup> - 1].
- left is less than or equal to right.
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Last modified on September 7, 2026