FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode/basic/sorting/QuickSort/QuickSort.go at main · ManolinCoder/leetcode · GitHub
ManolinCoder
leetcode
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode
/
basic
/
sorting
/
QuickSort
/
QuickSort.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (33 loc) · 633 Bytes
Breadcrumbs
leetcode
/
basic
/
sorting
/
QuickSort
/
QuickSort.go
Copy path
File metadata and controls
38 lines (33 loc) · 633 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package
main
import
"fmt"
func
partition
(
nums
[]
int
,
low
,
high
int
)
int
{
pivot
:=
nums
[
low
]
for
low
<
high
{
for
low
<
high
&&
nums
[
high
]
>=
pivot
{
high
--
}
nums
[
low
]
=
nums
[
high
]
for
low
<
high
&&
nums
[
low
]
<
pivot
{
low
++
}
nums
[
high
]
=
nums
[
low
]
}
nums
[
low
]
=
pivot
return
low
}
func
_quickSort
(
nums
[]
int
,
low
,
high
int
) {
if
low
>=
high
{
return
}
mid
:=
partition
(
nums
,
low
,
high
)
_quickSort
(
nums
,
low
,
mid
)
_quickSort
(
nums
,
mid
+
1
,
high
)
}
func
quickSort
(
nums
[]
int
) {
_quickSort
(
nums
,
0
,
len
(
nums
)
-
1
)
}
func
main
() {
nums
:=
[]
int
{
1
,
2
,
7
,
4
,
5
,
3
}
quickSort
(
nums
)
fmt
.
Println
(
nums
)
}
Back
|
FazBrowse Home
|
New Git URL