![]() |
VOOZH | about |
Given a value n, find out the largest palindrome number which is product of two n digit numbers.
Examples :
Input : n = 2 Output : 9009 9009 is the largest number which is product of two 2-digit numbers. 9009 = 91*99. Input : n = 3 Output : 906609
Below are steps to find the required number.
Below is the implementation of above steps.
Output :
9009
Time Complexity: O(n*n*log10(product)), where n is the upper limit calculated and product is (product of two n-digit numbers)
Auxiliary Space: O(1), as no extra space is required|
The approach used in this post is simple and straightforward. Please comment if you find a better approach.