Size of an array is n.All elements in the array are distinct in the range of [0 , n-1] except two elements.Find out repeated element without using extra temporary array with con
Lazy solution: Put the elements to java.util.Set one by one by add(E) until getting add(E)==false.
java.util.Set
add(E)
Sorry no constant-time. HashMap:O(N), TreeSet:O(lgN * N).