Skip to content

Commit 121ad5f

Browse files
committed
Runtime: 13 ms (Top 29.67%) | Memory: 225.1 MB (Top 38.94%)
1 parent 1ad8ef4 commit 121ad5f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1+
// Runtime: 13 ms (Top 29.67%) | Memory: 225.1 MB (Top 38.94%)
12
class Solution {
23
public int[] rearrangeArray(int[] nums) {
34
int[] res = new int[nums.length];
45
int resIdx = 0;
56
int posIdx = -1;
67
int minusIdx = -1;
78

8-
99
for(int i=0;i<nums.length;i++){
1010
if(i % 2 == 0){
1111
posIdx++;
1212
while(nums[posIdx] <0 )posIdx++;
13-
res[resIdx++] = nums[posIdx];
13+
res[resIdx++] = nums[posIdx];
1414
}
1515
else{
1616
minusIdx++;
1717
while(nums[minusIdx] > 0 )minusIdx++;
18-
res[resIdx++] = nums[minusIdx];
18+
res[resIdx++] = nums[minusIdx];
1919
}
2020
}
2121

22-
2322
return res;
2423
}
25-
}
24+
}

0 commit comments

Comments
 (0)