<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>

class Solution {
public:
    vector<long long> t;

    void progress(int a, int c, long long maxi10, long long maxi) {

        int noi = (c + 1) / 2;
        long long g = maxi10;
        string cp = "";

        for (int i = 1; i <= 9; i++) {
            if (a > maxi10) {
                a -= maxi10;
            } else {
                cp +=to_string(i);
                break;  
            }
        }
        maxi10 /= 10;
        // every digit would contribute in the formtion of equal palindrome?independency of numbers?

        for (int i = 2; i <= noi; i++) {
            for (int j = 0; j <= 9; j++) {
                if (a > maxi10) {
                    a -= maxi10;
                } else {
                    cp +=to_string(j);  // ye compilationb erro s aa ya tha mera
                    break;  
                }
            }
            maxi10 /= 10;
        }

        string ab=cp;
        if(c&1) ab.pop_back();
        // odd lenth mein beech wala character independent

        reverse(ab.begin(), ab.end());
        //shame shame ke liye
        
        


         cp=cp+ab;

        long long s = stoll(cp);
        t.push_back(s);
    }

    vector<long long> kthPalindrome(vector<int>& queries, int intLength) {
        vector<int> q = queries;
        int c = intLength;
        int op = queries.size();

        if (intLength == 1) {
            vector<long long> ans(queries.size(), -1);
            int j = 0;
            for (auto i : q) {
                if (i <= 9) {
                    ans[j] = i;
                }
                j++;
            }
            return ans;
        }

        // t = vector<long long>(op, -1);
        long long ab = (intLength - 1);
        ab /= 2;
        long long maxi = 9ll * static_cast<long long>(pow(10, ab));
        long long maxi10 = maxi / 9;

        for (int i = 0; i < op; i++) {
            if (q[i] <= maxi) { 
                progress(q[i], c, maxi10, maxi);
            }
            else 
            {
                t.push_back(-1);
            }
        }

        return t;
    }
};
63200