i
and j
to 0 and 1, respectively.i
is less than the length of the array:
a. If nums[i]
is even, increment i
by 2.
b. Otherwise, while j
is less than the length of the array and nums[j]
is odd, increment j
by 2.
c. If j
is less than the length of the array, swap nums[i]
and nums[j]
.
d. Increment i
by 2.nums
.