Search
⌘K

Leetcode 75. Sort Colors

Reorder an array of values 0, 1, and 2 in-place so all 0s come first, then 1s, then 2s (the Dutch National Flag problem); aim for a one-pass, constant-extra-space solution without using built-in sort.

Asked at:

Google

Google

Amazon

Amazon


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late October, 2024

Amazon

Amazon

Junior

Sort 0, 1, 2 (optimized to O(1) space and O(n) time)

Early October, 2024

Google

Google

Intern

Color n houses with k colors where no adjacent houses can have the same color, given that the colors of the first and last houses are fixed

Comments

Your account is free and you can post anonymously if you choose.