Find the largest palindrome made from the product of two n-digit numbers.
Since the result could be very large, you should return the largest palindrome mod 1337.
Example:
Input: 2
Output: 987
Explanation: 99 x 91 = 9009, 9009 % 1337 = 987
Note:
The range of n is [1,8].
<Solution>想法如下
- 因為要找最長的 palindrome,所以從兩個 n-digit 數字的最大乘積往下找
- 找到一個 palindrome 後,再去確認它是不是兩個 n-digit 數字的乘積
C++
Java
沒有留言:
張貼留言