Search⌘ K
AI Features

Sort Colors

Explore sorting an array containing colors red, white, and blue using integers 0, 1, and 2. Learn how to apply the two-pointer technique with a one-pass, in-place algorithm that uses constant extra space to group colors efficiently. This lesson helps you understand problem constraints and develop a solution aligned with coding interview best practices.

Statement

You are given an array nums of length n, where each element represents an object colored either ...