鏈結串列是由節點透過指針相連的線性資料結構。不支援隨機存取,但插入和刪除操作為 O(1)。
Notes:
- Dummy head node 可以大幅簡化邊界處理
- 快慢指針是鏈結串列題目的核心技巧
- 修改指針時要小心順序,避免斷鏈
跨倉庫導讀#
- 對應理論章節:線性資料結構 ↗
#2
Add Two Numbers
#19
Remove Nth Node From End of List
#21
Merge Two Sorted Lists
#23
Merge k Sorted Lists
#24
Swap Nodes In Pairs
#25
Reverse Nodes in k-Group
#61
Rotate List
#83
Remove Duplicates From Sorted List
#86
Partition List
#92
Reverse Linked List II
#138
Copy List with Random Pointer
#141
Linked List Cycle
#143
Reorder List
#146
LRU Cache
#147
Insertion Sort List
#148
Sort List
#160
Intersection of Two Linked Lists
#203
Remove Linked List Elements
#206
Reverse Linked List
#234
Palindrome Linked List
#287
Find the Duplicate Number
#460
LFU Cache
#622
Design Circular Queue
#707
Design Linked List
#725
Split Linked List in Parts
#876
Middle of the Linked List
#1472
Design Browser History
#1721
Swapping Nodes in a Linked List
#2130
Maximum Twin Sum Of A Linked List