A string a is a suffix of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning. A palindrome is a string that reads the same backward as forward, for example, strings "gg", "ioi", "abba", "icpci" are palindromes, ...
UVA # 11452 "Dancing the Cheeky-Cheeky" UVA 12604 - Caesar Cipher UVA 12467 - Secret Word UVA 11019 - Matrix Matcher SPOJ - Pattern Find SPOJ - A Needle in the Haystack Codeforces - Anthem of Berland Codeforces - MUH and Cube Walls Codeforces - Prefixes and Suffixes...
Inspired by this, we define the last array: //last[i][c]: Among 0 <= k <= i such that [0...k] is a prefix of [0,...,i] and [i-k,...,i] is a suffix of [0,...,i], the max k such that s[k+1]==c //For example, s = "abcabaabd", last[7]['d'] = ...