Input: nums =[4,3,2,1]Output: [0,0,1,1]Explanation:
* Replace the even numbers(4 and 2)with0 and the odd numbers(3 and 1)with1. Now,`nums = [0, 1, 0, 1]`.* After sorting `nums`in non-descending order,`nums = [0, 0, 1, 1]`.
Input: nums =[1,5,1,4,2]Output: [0,0,1,1,1]Explanation:
* Replace the even numbers(4 and 2)with0 and the odd numbers(1,5 and 1)with1. Now,`nums = [1, 1, 1, 0, 0]`.* After sorting `nums`in non-descending order,`nums = [0, 0, 1, 1, 1]`.
Replace even numbers with 0, odd numbers with 1, then sort. This is equivalent to counting the number of even and odd numbers and constructing the result.