As reported: AMD Senior Software System Designer, Bengaluru (2026), round 2 in person: an easy/medium coding question — sort an array containing 0s and 1s.
Given an array nums that contains only 0s and 1s, sort it in place so that all 0s come before all 1s. Aim for one pass and O(1) extra space.
Example 1
nums = [0,1,1,0,1,0] -> [0,0,0,1,1,1]
Example 2
nums = [1,1,1,0] -> [0,1,1,1]
Constraints: 1 ≤ nums.length ≤ 2 · 10^5.
Code runner format: one JSON value: nums. Implement sortBinary(nums) modifying nums in place; the harness prints nums.