...

/

Sort Array By Parity II

Sort Array By Parity II

Try to solve the Sort Array By Parity II problem.

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 [0,2,4,...][0, 2, 4, ...] ...