Sort Array By Parity
easy
1. Given an array nums of non-negative integers. 2. Arrange elements of array in specific order, all even elements followed by odd elements. [even -> odd] 3. Preserve the order of Even elements without using extra space. 4. Hence question is order specific so you have to match your output in order of given output.
Constraints
1. 1 <= nums.length <= 5000 2. 0 <= nums[i] <= 5000
Format
Input
7 9 3 8 7 6 2 3
Output
8 6 2 7 3 9 3 Explanation : {even -> odd}, 8 is before 6 in given input as well as in output, same for 6,2.
Example
Sample Input
7
9 3 8 7 6 2 3
Sample Output
8 6 2 7 3 9 3