def solution(a):
arr = []
for i in range(len(a)):
for j in range(i+1,len(a)):
if a[i]==a[j]:
hash.append(j)
if len(hash) == 0:
return -1
else:
idx = min(hash)
return a[idx]
a = [2, 3, 4, 6, 5, 3]
Solution(a)
def Solution(a):
arr = []
value=[]
for i in range(len(a)):
if a[i] not in hash:
hash.append(a[i])
else:
value.append(i)
if len(value) ==0:
return -1
else:
idx = min(value)
return a[idx]
# a = [1,2,3,4,4,2]
a=[1,2,3,4]
Solution(a)