topic:
1669. Merge two linked watches
Thought:
直接放上官方answer了,就yes模拟Linked。
topic要求将 list1
First a arrive b Delete all nodes,Replace it for list2
。therefore,我们首先找arrive list1
B a−1 Node preA,As well as b+1 Node aftB。because 1≤a≤b<n−1
(in n yes list1 length),so preA and aftB yes一定存在of。
Then we let us give up preA of next direction list2
of头节点,Give up list2
of尾节点of next direction aftB To。
Code:
1 | class ListNode(object): |