Dutch national flag

medium

Three pointers carve the array into four regions, and the loop shrinks the unknown one to nothing. The one line everyone gets wrong: on a 2, mid does not advance.

Worst O(n)Space O(1)
Loading the dutch national flag engine…

Where to go next