Recently, I was asked by one of my friends to find the next Palindrome number given an input number. What would be the best algorithm to find considering the Memory and runtime ? Tigers of the Software world - wanna give a shot at it ?
Input 3 34 99 101 345
Output 4 44 101 111 353
Update as on 30th of Sep 2010
There have been few hits to this page lately. It is not honest not to provide any solution. Palindromes could be strings or numbers. This one was for number , So I tried not to use string reverse and find the next palindrome. This was a mathematical find of the next palindrome. I could have done something wrong, let me know if there are.
Here is the code in java. This can be executed by just replacing the .txt to .java and after compiling.
No comments:
Post a Comment