diff --git a/go/1669-merge-in-between-linked-lists.go b/go/1669-merge-in-between-linked-lists.go new file mode 100644 index 000000000..33a52e952 --- /dev/null +++ b/go/1669-merge-in-between-linked-lists.go @@ -0,0 +1,30 @@ +/** + * Definition for singly-linked list. + * type ListNode struct { + * Val int + * Next *ListNode + * } + */ +func mergeInBetween(list1 *ListNode, a int, b int, list2 *ListNode) *ListNode { + curr := list1 + i := 0 + for i < a-1 { + curr = curr.Next + i++ + } + + head := curr + for i <= b { + curr = curr.Next + i++ + } + head.Next = list2 + + for list2.Next != nil { + list2 = list2.Next + } + + list2.Next = curr + + return list1 +}
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: