Solution: Sort Array By Parity II
Understand how to apply a modified cyclic sort with two pointers to rearrange an array so that all even numbers occupy even indexes and all odd numbers occupy odd indexes. This lesson helps you master an optimal in-place solution with linear time complexity and constant space usage.
We'll cover the following...
We'll cover the following...
Statement
You are given an integer array, nums, where exactly half of the elements are even, and the other half are odd.
Rearrange nums such that:
All even numbers are placed at even indexes
...