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