Skip to content

Commit 63c1fe1

Browse files
zhendonghuimhuay
authored andcommitted
Update 专题-A-数据结构.md (#29)
Update 合并排序链表——迭代实现 make the last node of the list point to nullptr.
1 parent 46fa4ea commit 63c1fe1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

C-算法/专题-A-数据结构.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,15 @@ public:
696696
}
697697
698698
// 别忘了拼接剩余部分
699-
if (p1) cur->next = p1;
700-
if (p2) cur->next = p2;
699+
// if (p1) cur->next = p1;
700+
// if (p2) cur->next = p2;
701+
if (p1) {
702+
cur->next = p1;
703+
} else if (p2) {
704+
cur->next = p2;
705+
} else {
706+
cur->next = nullptr;
707+
}
701708
702709
return head;
703710
}

0 commit comments

Comments
 (0)