Given an array of n
unique integers in [1, n], take random k
elements away from the array, then shuffle it to be left with an array of size n-k
of integers of size n-k
I want to find those k
integers in the best complexity.
If k==1
, we can sum all the elements in the array, and the missing element would be the difference between n(n+1)/2
(sum of all numbers from 1 to n) and the sum of the array elements.
I would like to extend this algorithm to k
missing elements by k equations, but don't know how to build the equations. Can it be done?