deno.land / x / masx200_leetcode_test@10.6.5 / merge-in-between-linked-lists / index.ts

نووسراو ببینە
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
import { get_deep_next_of_list as get_deep_next_of_list,} from "../reverse-linked-list-ii/get_deep_next_of_list.ts";import { ListNode } from "../reverse-linked-list/ListNode.ts";import { getEndOfList } from "./get_end_of_list.ts";
export default function mergeInBetween( list1: ListNode | null, a: number, b: number, list2: ListNode | null,): ListNode | null { if (!list1) { return list1; } if (!list2) { return list1; } const start_of_first = list1; const end_of_list2 = getEndOfList(list2);
const end_of_first = get_deep_next_of_list(list1, a - 1); const start_of_third = get_deep_next_of_list(end_of_first, b - a + 2); end_of_first.next = list2; end_of_list2.next = start_of_third; return start_of_first;}
masx200_leetcode_test

Version Info

Tagged at
a year ago