Smallest Absent Positive — Solution & Editorial
The answer is at most N+1. A presence set (or in-place index marking for O(1) memory) and a scan from 1 upward.
Complexity: O(N)
The answer is at most N+1. A presence set (or in-place index marking for O(1) memory) and a scan from 1 upward.
Complexity: O(N)