Skip to content

Commit

Permalink
Update 01.Linked-List-Sort.md
Browse files Browse the repository at this point in the history
  • Loading branch information
itcharge committed Aug 30, 2022
1 parent 0d5b6f6 commit b42d022
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ class Solution:
3. 对左右两个链表分别进行递归分割,直到每个链表中只包含一个链节点。
2. **归并环节**:将递归后的链表进行两两归并,完成一遍后每个子链表长度加倍。重复进行归并操作,直到得到完整的链表。
1. 使用哑节点 `dummy_head` 构造一个头节点,并使用 `cur` 指向 `dummy_head` 用于遍历。
2. 比较两个链表头节点 `left``right` 的值大小。将较小的头节点加入到合并后的链表中并向后移动该链表的头节点指针。
2. 比较两个链表头节点 `left``right` 的值大小。将较小的头节点加入到合并后的链表中并向后移动该链表的头节点指针。
3. 然后重复上一步操作,直到两个链表中出现链表为空的情况。
4. 将剩余链表插入到合并中的链表中
4. 将剩余链表插入到合并后的链表中
5. 将哑节点 `dummy_dead` 的下一个链节点 `dummy_head.next` 作为合并后的头节点返回。

### 5.2 链表归并排序实现代码
Expand Down

0 comments on commit b42d022

Please sign in to comment.