Skip to content

Commit f2e1c3e

Browse files
refactor 922
1 parent f2e67a6 commit f2e1c3e

File tree

1 file changed

+1
-20
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+1
-20
lines changed

src/main/java/com/fishercoder/solutions/_922.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 922. Sort Array By Parity II
5-
*
6-
* Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.
7-
* Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, i is even.
8-
* You may return any answer array that satisfies this condition.
9-
*
10-
* Example 1:
11-
*
12-
* Input: [4,2,5,7]
13-
* Output: [4,5,2,7]
14-
* Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted.
15-
*
16-
*
17-
* Note:
18-
* 2 <= A.length <= 20000
19-
* A.length % 2 == 0
20-
* 0 <= A[i] <= 1000
21-
* */
223
public class _922 {
234
public static class Solution1 {
245
public int[] sortArrayByParityII(int[] A) {
25-
for (int i = 0, j = 1; i < A.length - 1 && j < A.length;) {
6+
for (int i = 0, j = 1; i < A.length - 1 && j < A.length; ) {
267
if (A[i] % 2 != 0 && A[j] % 2 == 0) {
278
int tmp = A[i];
289
A[i] = A[j];

0 commit comments

Comments
 (0)