Sort Array By Parity
EasyTwo Pointers
Decode it first. Clues, constraints, pattern and plan before any code.Given a list of non-negative integers nums, move all the even numbers before all the odd numbers and return the list. Any order within the evens and within the odds is accepted. Try to do it in place with O(1) extra space.
nums = [3, 1, 2, 4] → [2, 4, 3, 1] ([4, 2, 3, 1], [2, 4, 1, 3] and [4, 2, 1, 3] are also fine)
nums = [0] → [0]Constraints
1 <= nums.length <= 50000 <= nums[i] <= 5000