Solution: Sort Array By Parity II
Understand how to use a modified cyclic sort combined with two pointers to reorder arrays by parity. This lesson enables you to efficiently place even numbers at even indexes and odd numbers at odd indexes in-place, achieving optimal time and space complexity.
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
...