So imagine the string is all numbers, how can i find the largest palindrome in the string Ex. 192929119382282 The current palindromes are 1929291 92929 2929 9119 8228 282 11 22 How can the program tell me that 1929291 is the largest.
Asked
Active
Viewed 280 times
1 Answers
0
- You need to loop through string starting with first character, then in the loop try to find the position where character repeated itself.
- Now the portion between first char and repeat char, you can pass it to a function to check if it is palindrome.
- If it is palindrome, find out it's length and check it with last length value which will be zero initially.
- if it is larger than last length value, store chunk of string as answer. Also, save length for future comparisons.
- Continue like this till the end of the string. At the end of the loop, the answer variable will contain largest palindrome.

Harsh
- 1,309
- 8
- 14