Given an array of integers arr, modify it in place to put all even numbers before all odd numbers. The relative order between even numbers does not matter. Same for the odd numbers.
Example 1:
- Input:
arr = [3, 1, 2, 4, 6] - Output:
[2, 4, 6, 1, 3] - Explanation: [4, 2, 6, 3, 1] is also accepted.
Example 2:
- Input:
arr = [1, 1, 1, 1] - Output:
[1, 1, 1, 1]
l
3
0
1
1
2
2
4
3
r
6
4
Step 1 / 6
Step 1:
Initialize pointers l=0, r=4.
Pointers: l=0, r=4
Focus: select @ [0, 4]