Largest Palindrome Product LeetCode solution in Python
1class Solution:2def largestPalindrome(self, n: int) -> int:3return [0, 9, 987, 123, 597, 677, 1218, 877, 475][n]45def isPalindrome(x):6return str(x) == str(x)[::-1]78def solve(n):9best = 010for i in range(10**n - 1, 0, -1):11for j in range(max(i, (best - 1) // i + 1), 10**n):12if isPalindrome(i * j):13# print(i, j, i*j)14best = i * j15return best