leetle

Daily challenge for 2025-09-08

251. Sort Colors

Write a function solve that sorts an array nums containing only 0s, 1s, and 2s in-place so that elements of the same value are adjacent, in the order 0, then 1, then 2. Return the sorted array.

Example:
Input: nums = [2,0,2,1,1,0]
Output: [0,0,1,1,2,2]

Run this challenge interactively in Python or JavaScript when the app loads.