Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int[] sortArrayByParity(int[] A) {
- int[] result = new int[A.length];
- int lo = 0;
- int hi = A.length - 1;
- for (int i = 0; i < A.length; i++) {
- if (A[i] % 2 == 0) {
- result[lo++] = A[i];
- }
- else {
- result[hi--] = A[i];
- }
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement