Easy python solution using list o(n)


#1

def solve(self, A):
lst=[]
res1=""
res2=""
i=0
j=len(A)-1
while i<=j:
if A[i]==A[j]:
i+=1
j-=1
else:
lst.append(i)
lst.append(j)
break
if not lst:
return 1
i=lst[0]
j=lst[1]
res1 = A[:i]+A[i+1:]
res2=A[:j]+A[j+1:]
if res1==res1[::-1]:
return 1
elif res2==res2[::-1]:
return 1
else:
return 0