If A has size 3 and maximum element 10 |
Something like {1,4,10}
then the first missing integer must be less than 4 |
Right, here 2.
(in this example the size of the boolVals array is determined by the size of the original array). |
Yes, the bool array will first be {0, 0, 0, 0} then only the position one will be set to 1 (line 8). So staring from the beginning, our result will be 2, as expected.
If A has size 10 and maximum element 2 |
Something like {-4, 1, -3, -3, 0, -5, 1, 2, -1, -6}
then the first missing element can be at most 3 |
Right. As mentioned above we define the bool array: {0,0,0,0,0,0,0,0,0,0, 0}, and set positions that are greater than 0 and less than or equal to 10: {0,1,2,0,0,0,0,0,0,0, 0}. So again, starting from the beginning we will have 3 as the result.
(in this example the size of the boolVals array is determined by the maximum value that the original array holds) |
It was the case in the penultimate algorithm. In the last one that issue is not taken into account.
Likely I'm too tried that can't get your point that's why I asked you for an example. I meant an array example. For instance, give me an array given to the project it will send out a not completely right answer.