Sort Array by Parity
Easy
Arrays
Array
Sorting
Return array with even numbers first, then odd. Print space-separated.
Constraints
1 ≤ nums.length ≤ 5000
Examples
Example 1:
Input: 3 1 2 4
Output: 2 4 3 1
Example 2:
Input: 0
Output: 0
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console