⌘K
Flycodx

Zomato Delivery Sort Zones Dutch Flag

Zomato Delivery Sort Zones Dutch Flag

EasySorting50% accepted

Zomato delivery zones are coded 0 (red), 1 (white), 2 (blue). Sort array in-place so all 0s come first, then 1s, then 2s. Use O(1) extra space and one pass.

Approach

Sort array of 0s, 1s, and 2s in-place (Dutch National Flag problem).

Input

6 2 0 2 1 1 0

Output

0 0 1 1 2 2
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3