This page shows a solution to the problem StrSymmetryPoint presented by Codility in the lesson 99 “ Future Training”.

def solution(S): if len(S) % 2 == 0: return -1 for i in xrange(len(S)//2): if S[i] != S[-i-1]: return -1 return len(S)//2

The worst-case time complexity is O(length(S)). The worst-case space complexity is constant.