Find the Duplicate
Saturday, October 13th, 2007Dany Valevsky gave me this very cool riddle.
You are given a vector of size N, the elements of which are numbers in the range 1,…,N-1. I.e. there is at least one repeating element. Give an algorithm that finds a repeating element (it does not matter which one, in case there are several) with O(N) time complexity and O(log(N)) memory complexity.
I recently watched 


