Skip to content

Practice Find Palindrome With Fixed Length

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2217
LeetCode Problem

Find Palindrome With Fixed Length

Problem Statement

Given an integer array queries and a positive integer intLength, return an array answer where answer[i] is either the queries[i]th smallest positive palindrome of length intLength or -1 if no such palindrome exists. A palindrome is a number that reads the same backwards and forwards. Palindromes cannot have leading zeros.

Source: Find Palindrome With Fixed Length on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
queries = [1,2,3,4,5,90], intLength = 3
Output
[101,111,121,131,141,999]

# Example 2

Input
queries = [2,4,6], intLength = 4
Output
[1111,1331,1551]

Constraints

1 <= queries.length <= 5 * 10^4
1 <= queries[i] <= 10^9
1 <= intLength <= 15

Related LeetCode Problems

Practice more problems similar to Find Palindrome With Fixed Length.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.