Skip to content

Commit 4304da7

Browse files
Time: 1 ms (99.04%), Space: 40.1 MB (29.76%) - LeetHub
1 parent 933ba39 commit 4304da7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Solution {
2+
public int[] sortArrayByParity(int[] nums) {
3+
4+
int i=0,j=0;
5+
while(i<nums.length)
6+
{
7+
if(nums[i]%2==0)
8+
{
9+
int temp=nums[i];
10+
nums[i]=nums[j];
11+
nums[j]=temp;
12+
i++;
13+
j++;
14+
}
15+
else
16+
{
17+
i++;
18+
}
19+
}
20+
21+
return nums;
22+
23+
}
24+
}

0 commit comments

Comments
 (0)