Simple three lines code in python

class Solution:
# @param A : list of integers
# @return an integer
def solve(self, A):
    for i in range(len(A)):
        if A[i] in A[i+1:]:
            return A[i]
            
    return -1

This is not passing all the test cases

Click here to start solving coding interview questions