Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit26382bf

Browse files
authored
Merge pull request#3177 from ashishsingh1508/patch-2
Create 0147-insertion-sort-list.go
2 parents824a14b +28644e0 commit26382bf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎go/0147-insertion-sort-list.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* type ListNode struct {
4+
* Val int
5+
* Next *ListNode
6+
* }
7+
*/
8+
funcinsertionSortList(head*ListNode)*ListNode {
9+
dummy:=new(ListNode)
10+
forhead!=nil {
11+
cur:=dummy
12+
for ;cur.Next!=nil&&cur.Next.Val<head.Val;cur=cur.Next {
13+
}
14+
cur.Next,head.Next,head=head,cur.Next,head.Next
15+
}
16+
returndummy.Next
17+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp