Given an integer n, return the largest palindromic integer that can be represented as the product of two n-digits integers. Since the answer can be very large, return it modulo 1337.

&nbsp;
Example 1:

Input: n = 2
Output: 987
Explanation: 99 x 91 = 9009, 9009 % 1337 = 987


Example 2:

Input: n = 1
Output: 9


&nbsp;
Constraints:


	1 &lt;= n &lt;= 8


class Solution:
    def largestPalindrome(self, n: int) -> int:
        return [0, 9, 987, 123, 597, 677, 1218, 877, 475][n]

        
    def isPalindrome(x):
        return str(x) == str(x)[::-1]

    def solve(n):
        best = 0
        for i in range(10**n-1, 0, -1):
            for j in range(max(i, (best-1)//i+1), 10**n):
                if isPalindrome(i*j):
                    #print(i, j, i*j)
                    best = i*j
        return best
class Solution {
    public int largestPalindrome(int n) {
        if(n == 1 ){
            return 9;
        }
       if(n == 2){
           return 987;
       }
        if(n == 3){
            return 123;
        }
        if(n == 4){
            return 597;
        }
        if(n == 5){
            return  677;
        }
        if(n == 6){
            return 1218;
        }
        if(n == 7){
            return 877;
        }
        return 475;
        
    }
}
class Solution {
public:
    int largestPalindrome(int n) {
        if(n==1)
        {
            return 9;
        }
        int hi=pow(10,n)-1;
        int lo=pow(10,n-1);
        int kk=1337;
        for(int i=hi;i>=lo;i--)
        {
            string s=to_string(i);
            string k=s;
            reverse(k.begin(),k.end());
            s+=k;
            long long int ll=stol(s);
            for(int j=hi;j>=sqrtl(ll);j--)
            {
                if(ll%j==0)
                {
                    return ll%kk;
                }
            }
            
        }
        return 0;
    }
};
/**
 * @param {number} n
 * @return {number}
 */
var largestPalindrome = function(n) {
    if (n === 1) return 9;
    let hi = BigInt(Math.pow(10, n) - 1);
    let num = hi;
    while(num > 0) {
        num -= 1n;
        const palindrome = BigInt(String(num) + String(num).split('').reverse().join(''));
        for (let i = hi; i >= 2n; i -= 2n) {
            const j = palindrome / i; 
            if (j > hi) break;
            if (palindrome % i === 0n) {
                return String(palindrome % 1337n);
            };
        }
    }
};
Largest Palindrome Product