FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode/basic/sorting/SelectionSort/SelectionSort.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
/
SelectionSort
/
SelectionSort.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
21 lines (18 loc) · 356 Bytes
Breadcrumbs
leetcode
/
basic
/
sorting
/
SelectionSort
/
SelectionSort.go
Copy path
File metadata and controls
21 lines (18 loc) · 356 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
package
main
import
"fmt"
func
selectionSort
(
nums
[]
int
) {
for
i
,
n
:=
0
,
len
(
nums
);
i
<
n
-
1
;
i
++
{
minIndex
:=
i
for
j
:=
i
+
1
;
j
<
n
;
j
++
{
if
nums
[
j
]
<
nums
[
minIndex
] {
minIndex
=
j
}
}
nums
[
minIndex
],
nums
[
i
]
=
nums
[
i
],
nums
[
minIndex
]
}
}
func
main
() {
nums
:=
[]
int
{
1
,
2
,
7
,
9
,
5
,
8
}
selectionSort
(
nums
)
fmt
.
Println
(
nums
)
}
Back
|
FazBrowse Home
|
New Git URL