Search⌘ K
AI Features

Sort Colors

Understand how to sort an array containing colors represented by 0, 1, and 2 using the two-pointers technique. Learn to solve this problem efficiently in linear time and constant space by rearranging elements in place without built-in sort functions.

Statement

Given an array, colors, which contains a combination of the following three elements:

    ...