Valentas
Well-Known Member
- Local time
- Today 2:58 AM
- Joined
- Jun 20, 2012
- Messages
- 506
Okay, basically I've spot this problem, I believe that it may be interesting to @Architect
Missing numbers. Imagine you are given a list of slightly less than 1,000,000 numbers, all different, and each between 0 and 999,999 inclusive. How could you find (in a reasonable time) a number between 0 and 999,999 that is not on the list?
My notion is that there is only one number missing because it is explicitly stated in the end.
I think firstly it is important to cut the list in half so I'd make an array of numbers {"0", "1", "2", ... "499999"} and check its length. If it has all numbers than we proceed to the other half....maybe someone could show how to solve this problem for example in Java?
Missing numbers. Imagine you are given a list of slightly less than 1,000,000 numbers, all different, and each between 0 and 999,999 inclusive. How could you find (in a reasonable time) a number between 0 and 999,999 that is not on the list?
My notion is that there is only one number missing because it is explicitly stated in the end.
I think firstly it is important to cut the list in half so I'd make an array of numbers {"0", "1", "2", ... "499999"} and check its length. If it has all numbers than we proceed to the other half....maybe someone could show how to solve this problem for example in Java?
