Find the Largest Palindrome Divisible by K
You are given two positive integers n and k.
An integer x is called k-palindromic if:
xis a palindrome.xis divisible byk.
Return the largest integer having n digits, as a string, that is k-palindromic.
Note that the integer must not have leading zeros.
Example 1
Input
n = 3, k = 5Output
"595"595 is the largest k-palindromic integer with 3 digits.
Example 2
Input
n = 1, k = 4Output
"8"4 and 8 are the only k-palindromic integers with 1 digit, so 8 is the largest.
Constraints
- 1 <= n <= 10^5
- 1 <= k <= 9