Problems > Smallest Absent Positive > Editorial

Smallest Absent Positive — Solution & Editorial

Back to the Problem

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)