Why this solution is not o(n)


#1
class Solution:
    # @param A : string
    # @return an integer
    def solve(self, A):
        B=A
        for i in range(len(A)):
            A=A[:i]+A[i+1:]
            if A==A[::-1]:
                return 1
            else: A=B
        return 0

#3

It costs O(n) just to build a substring and to compare it with it’s reverse. Together with the O(n) outer loop you get O(n²).


#4

@ wing-chung-leung it helped, :slight_smile: