How to sort arrays by parity in leetCode
LeetCode in how to sort the array by parity, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
First, sort the array II1 by parity, a brief description of the problem.
Given a non-negative integer array A, half of the integers in An are odd and half of the integers are even.
Sort the array so that when A [I] is odd, I is also odd; when A [I] is even, I is even.
You can return any array that meets the above criteria as an answer.
2. Example description example:
Input: [4, 2, 5, 7]
Output: [4, 5, 5, 2, 7]
Explanation: [4, 7, 2, 5], [2, 5, 5, 4, 7], [2, 7, 4, 5] will also be accepted.
Tip:
two