status
date
slug
tags
category
type
password
icon
 
本文目錄

前言

經典單鍊表

LeetCode 021. Merge Two Sorted Lists

  • Dummy Node 的運用
 

LeetCode 086. Partition List

  • 當舊鏈表的節點被指派到新鏈表時 ⇒ 斷開舊鏈表的連接
 

LeetCode 23. Merge k Sorted Lists

  • 自定義 Priority Queue 的比較函式
 

LeetCode 019. Remove Nth Node From End of List

  • 快慢指標
 

LeetCode 876. Middle of the Linked List

 

LeetCode 141. Linked List Cycle

  • 判斷鏈表中是否有環 ⇒ 快慢指標相遇即有環存在

LeetCode 142. Linked List Cycle II

  • 找出鏈表中環的起點 ⇒ 快慢指標相遇後,再將任意指標指回頭節點,同速並行直到相遇的節點即環的起點
 
 

LeetCode 160. Intersection of Two Linked Lists

  • 找到兩條鍊表的交點 ⇒ 兩個指標分別走過 ,相等時所在節點即交點
 

LeetCode 109. Convert Sorted List to Binary Search Tree

  • 構造 BST
 

LeetCode 83. Remove Duplicates from Sorted List

 

反轉鍊表

反轉鍊表模板

 

反轉前 N 個節點

LeetCode 92. Reverse Linked List II

LeetCode 25. Reverse Nodes in k-Group

LeetCode 234. Palindrome Linked List

  • 快慢指標判斷鍊表中點時,若是鍊表長度為奇數,慢指標需要多前進一格。

LeetCode

LeetCode

LeetCode

回溯法 隨筆雙指標 隨筆
Loading...
Zixu
Zixu
Welcome to my webstie.
Analytics
Post Count:
224
Latest posts
還好我退了 部隊篇
2025/08/08
泡泡
2025/08/05
還好我退了 新訓篇
2025/08/02
大學畢業心得
2025/07/12
AP325 隨筆
2025/06/07
Lycoris Recoil 莉可麗絲
2025/05/04