Home

πŸ‡ΊπŸ‡Έ MURICAAAA o7

Given an array nums with n objects colored red, white, or blue, sort nums in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. Return nums once sorted.

The integers 0, 1, and 2 will represent the color red, white, and blue, respectively. Can you come up with an O(n) algorithm using O(1) space?

See more: Edward Dijkstra's Dutch national flag problem.

murica([2, 0, 2, 1, 1, 0]) β†’ [0, 0, 1, 1, 2, 2]
murica([2, 0, 1]) β†’ [0, 1, 2]
murica([0]) β†’ [0]

😳 TIME LEFT: seconds 😳

function murica(nums) {

}

⏰ TOTAL TIME: seconds ⏰