Class Solution

java.lang.Object
g0901_1000.s0906_super_palindromes.Solution

public class Solution extends Object
906 - Super Palindromes.<p>Hard</p> <p>Let&rsquo;s say a positive integer is a <strong>super-palindrome</strong> if it is a palindrome, and it is also the square of a palindrome.</p> <p>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>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> left = &ldquo;4&rdquo;, right = &ldquo;1000&rdquo;</p> <p><strong>Output:</strong> 4</p> <p><strong>Explanation:</strong> 4, 9, 121, and 484 are superpalindromes. Note that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrome.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> left = &ldquo;1&rdquo;, right = &ldquo;2&rdquo;</p> <p><strong>Output:</strong> 1</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= left.length, right.length <= 18</code></li> <li><code>left</code> and <code>right</code> consist of only digits.</li> <li><code>left</code> and <code>right</code> cannot have leading zeros.</li> <li><code>left</code> and <code>right</code> represent integers in the range <code>[1, 10<sup>18</sup> - 1]</code>.</li> <li><code>left</code> is less than or equal to <code>right</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • superpalindromesInRange

      public int superpalindromesInRange(String left, String right)