FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/Week_01/id_134/LeetCode_905_134.java at master · feixiangcode/algorithm · GitHub
feixiangcode
/
algorithm
Public
forked from
algorithm001/algorithm
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
Week_01
/
id_134
/
LeetCode_905_134.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (24 loc) · 615 Bytes
Breadcrumbs
algorithm
/
Week_01
/
id_134
/
LeetCode_905_134.java
Copy path
File metadata and controls
24 lines (24 loc) · 615 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//https://leetcode.com/problems/sort-array-by-parity/
class
Solution
{
public
int
[]
sortArrayByParity
(
int
[]
A
) {
if
(
A
==
null
)
return
null
;
int
left
=
0
,
right
=
A
.
length
-
1
;
while
(
left
<
right
) {
if
((
A
[
left
] &
1
) ==
0
) {
left
++;
continue
;
}
if
((
A
[
right
] &
1
) ==
1
) {
right
--;
continue
;
}
int
tmp
=
A
[
left
];
A
[
left
] =
A
[
right
];
A
[
right
] =
tmp
;
left
++;
right
--;
}
return
A
;
}
}
Back
|
FazBrowse Home
|
New Git URL