0041. First Missing Positive
Cyclic Sort / Index Mapping — O(n) time, O(1) space
nums =
Load
[1,2,0]
[3,4,-1,1]
[7,8,9,11,12]
[1,2,3,4,5]
[2,1]
[1,1,1]
[-1,4,2,1,9,10]
[5,3,1,4,2]
Step
Play
Reset
Speed:
5x
Step 0
Press Step or Play to begin
Array State
Ready. Load an array and press Step or Play.
Result will appear here after the algorithm finishes.
Current (i)
Swap target
Correct position
Scanning
Missing found