Smallest python solution without dp


#1

class Solution:
# @param A : string
# @return an integer
def anytwo(self, A):
r = set()
lis = []
for index, items in enumerate(A):
if items in r:
# print(lis)
bb = set(lis[lis.index(items) + 1:])
for its in A[index + 1:]:
if its in bb:
return 1
else:
bb.add(its)
r.add(items)
lis.append(items)
return 0