Sort Colors (Flag Problem) Problem
Sort Colors (Flag Problem) Problem — ExecCode Easy DSA Practice
Solve the Sort Colors (Flag Problem) problem on ExecCode. Free online easy DSA practice in Sort. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given the input needed to solve Sort Colors (Flag Problem). Your task is to compute the required answer and return JSON array string. A text tool receives characters in a specific order. In Sort Colors (Flag Problem), the answer depends on handling those characters carefully, including duplicates and order. JSON nums.
Examples
Input {"nums": [2, 0, 2, 1, 1, 0]}; Output [0,0,1,1,2,2]. Input {"nums": [2, 0, 1]}; Output [0,1,2]. Input {"nums": [0]}; Output [0]
Constraints
O(n) time O(1) space
Practice Sort Colors (Flag Problem) free on ExecCode. Browse DSA problems, topic map, and placement guides.