← ALL NOTES
Array

41. First Missing Positive

The answer is always somewhere in [1, n+1]: if the array holds every value 1..n, it's n+1; otherwise it's the first gap. The O(1)-memory constraint rules out a hash set — so use the array itself as…

Loading…