Missing Number

Apart from a few programming puzzles, I never really got to work extensively on 'Bit Array' operations. So, as was practicing a bit, I got an idea for a problem, for which I posted a solution already (Software Job - Interview Question). This problem is about finding the missing number, in a array of unsorted numbers. For Ex: We have numbers from 1 to 52 that are put into a 51 number array, what's the best way to find out which number is missing?

As per the idea in that earlier post, the code would look like:



An other solution is to use Java's BitSet, as in the below listed code. Also, note that the following logic is also good for finding multiple missing numbers. So, the below code is a better approach to find one or more than one missing numbers: