Here is one of my interview question. Given an array of N elements and where an element appears exactly N/2 times and the rest N/2 elements are unique>
Algorithm RepeatedElement(a, n)
RepeatedElement(a, n)
while (true) do { i=Random() mod n+1; j=Random() mod n+1; // i and j are random numbers in the range [1,n] if ((i ≠ j) and a[i]=a[j])) then return; }