java.lang.Object
g2201_2300.s2217_find_palindrome_with_fixed_length.Solution

public class Solution extends Object
2217 - Find Palindrome With Fixed Length.<p>Medium</p> <p>Given an integer array <code>queries</code> and a <strong>positive</strong> integer <code>intLength</code>, return <em>an array</em> <code>answer</code> <em>where</em> <code>answer[i]</code> <em>is either the</em> <code>queries[i]<sup>th</sup></code> <em>smallest <strong>positive palindrome</strong> of length</em> <code>intLength</code> <em>or</em> <code>-1</code> <em>if no such palindrome exists</em>.</p> <p>A <strong>palindrome</strong> is a number that reads the same backwards and forwards. Palindromes cannot have leading zeros.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> queries = [1,2,3,4,5,90], intLength = 3</p> <p><strong>Output:</strong> [101,111,121,131,141,999]</p> <p><strong>Explanation:</strong></p> <p>The first few palindromes of length 3 are:</p> <p>101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, &hellip;</p> <p>The 90<sup>th</sup> palindrome of length 3 is 999.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> queries = [2,4,6], intLength = 4</p> <p><strong>Output:</strong> [1111,1331,1551]</p> <p><strong>Explanation:</strong></p> <p>The first six palindromes of length 4 are:</p> <p>1001, 1111, 1221, 1331, 1441, and 1551.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= queries.length <= 5 * 10<sup>4</sup></code></li> <li><code>1 <= queries[i] <= 10<sup>9</sup></code></li> <li><code>1 <= intLength <= 15</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • kthPalindrome

      public long[] kthPalindrome(int[] queries, int intLength)