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

Commit4d20a70

Browse files
authored
Merge pull requestneetcode-gh#3358 from xtommas/main
Create 1669-merge-in-between-linked-lists.go
2 parents894619e +4b0f977 commit4d20a70

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* type ListNode struct {
4+
* Val int
5+
* Next *ListNode
6+
* }
7+
*/
8+
funcmergeInBetween(list1*ListNode,aint,bint,list2*ListNode)*ListNode {
9+
curr:=list1
10+
i:=0
11+
fori<a-1 {
12+
curr=curr.Next
13+
i++
14+
}
15+
16+
head:=curr
17+
fori<=b {
18+
curr=curr.Next
19+
i++
20+
}
21+
head.Next=list2
22+
23+
forlist2.Next!=nil {
24+
list2=list2.Next
25+
}
26+
27+
list2.Next=curr
28+
29+
returnlist1
30+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp