Given an array of n+1 integers, each in the range 1 to n, find an integer that is repeated.
I was asked this at a job intervi
How about this simple solution:
start creating a binary search tree from the array. Whenever there is an element already present which is a duplicate while you are inserting into the BST then store that element in another array of duplicate elements and continue your loop .we don't even need to sort the array for finding the duplicates here.
This is just my idea.I was asked the same question in one of the interviews and this was my answer.