<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>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> queries = [1,2,3,4,5,90], intLength = 3
<strong>Output:</strong> [101,111,121,131,141,999]
<strong>Explanation:</strong>
The first few palindromes of length 3 are:
101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, ...
The 90<sup>th</sup> palindrome of length 3 is 999.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> queries = [2,4,6], intLength = 4
<strong>Output:</strong> [1111,1331,1551]
<strong>Explanation:</strong>
The first six palindromes of length 4 are:
1001, 1111, 1221, 1331, 1441, and 1551.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= queries.length &lt;= 5 * 10<sup>4</sup></code></li>
	<li><code>1 &lt;= queries[i] &lt;= 10<sup>9</sup></code></li>
	<li><code>1 &lt;= intLength&nbsp;&lt;= 15</code></li>
</ul>

def find_Length_of_baseNumbers(intLength: int):
    if intLength % 2 == 0:
        baseLength = intLength // 2
    else:
        baseLength = (intLength + 1) // 2
    return baseLength

def find_Source_of_baseNumbers(intLength: int):
    baseLength = find_Length_of_baseNumbers(intLength)
    source = 10 ** (baseLength - 1)
    return source

def Quantity_of_baseNumbers(source: int):
    quantity_bases = 9 * source
    return quantity_bases
   
def find_baseNumber(source: int, numOrder: int):
    base_num = source + numOrder
    return base_num

def build_Palindrome(base_num: int, intLength: int):
    base_lst = list(str(base_num))
    base_lst.extend([''] * (intLength - len(base_lst)))
    lo = 0
    hi = intLength - 1
    while lo < hi :
        base_lst[hi] = base_lst[lo]
        lo += 1
        hi -= 1
    base_num = int(''.join(base_lst))
    return base_num

def find_palindromeArray(queries: List[int], intLength: int):
    base_array = []
    answers = []
    source = find_Source_of_baseNumbers(intLength)
    quantity = Quantity_of_baseNumbers(source)
    i = 0
    for query in queries:
        numOrder = query - 1
        if numOrder < quantity:
            base_num = find_baseNumber(source, numOrder)
            palindrome = build_Palindrome(base_num, intLength)
            answers.append(palindrome)
        else:
            answers.append(-1)
    return answers
class Solution:
    def kthPalindrome(self, queries: List[int], intLength: int) -> List[int]:
        return find_palindromeArray(queries, intLength)
        
515