class Solution:
# @param {string} s
# @return {string}
def shortestPalindrome(self, s):
A=s+"*"+s[::1]
cont=[0]
for i in range(1,len(A)):
index=cont[i1]
while(index>0 and A[index]!=A[i]):
index=cont[index1]
cont.append(index+(1 if A[index]==A[i] else 0))
return s[cont[1]:][::1]+s
Python solution(KMP)


This is very interesting solution based on KMP. Actually, it is based on the failure function or KMPtable.
And it's pretty cool that the above solution is accepted by leetcode :).However, the Solution is apparently failed in the case "aabba". The call on shortestPalindrome function will return "aabba" while the correct answer should be "abbaabba".
This is a tricky issue. Leetcode please check.
