Find the largest palindrome in a given word.
Anonymous
Assume a single character is a palindrome of size 1. To begin, iterate starting at the beginning of the list. If element[i-1] == element[i+1], then continue continue checking with 1 replaced with 2, and so forth. Eventually you'll arrive at a contradiction; set currentBest accordingly. Continue to end of list, replacing currentBest as needed. One optimization, if (currentMax/2 > arrayLength - i) then stop searching; It is impossible to find a longer palindrome with the remaining portion of the list.
Check out your Company Bowl for anonymous work chats.