NeetCode #93LC-75MediumArrays & HashingNC 250
← Back to All Problems

#93 · #75 · Sort Colors(颜色分类)

📌 Problem Statement & Constraints

Given an array nums with n objects coloured red (0), white (1) or blue (2), sort them in place so that objects of the same colour are adjacent, in the order red, white, blue. You must solve it without using the library sort function, ideally in a single pass. Constraints: 1 <= n <= 300, nums[i] is 0, 1 or 2.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!