Given an integer array A of size N, find the first repeating element in it.
We need to find the element that occurs more than once and whose index of first occurrence is smallest.
If there is no repeating element, return -1.
1 <= N <= 105
1 <= A[i] <= 109
First and only argument is an integer array A of size N.
Return an integer denoting the first repeating element.
A = [10, 5, 3, 4, 3, 5, 6]
A = [6, 10, 5, 4, 9, 120]
5 is the first element that repeats
There is no repeating element, output -1
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.