922. Sort array by parity Ⅱ
Title description
Ideas, algorithms and code implementation
Method 1: Define two empty lists odd[] and even[] to store odd and even numbers respectively, and then put the numbers in odd[] and even[] into the result list res[] in turn.
Method 2: Define two empty lists odd[] and even[] to store the element position indexes of A[] that should be odd and even, and finally exchange odd and even numbers.