Question

Let B be an array that is of size n >= 6 containing integers from 1 to n-5, inclusive, with exactly five repeated. Describe an O(n) algorithm for finding the five integers in B that are repeated.

EXPERT ANSWER

To satisfy the O(n) complexity requirement, we need to go through the array at most constant number of times, usually once. What we can do here is that we can generate another array