LeetCode 連結串列題總結
阿新 • • 發佈:2020-12-12
最近花了幾天時間,將連結串列題除帶鎖外的題目做完了,下面對連結串列題部分題目進行總結和分析。
連結串列題目解決方法
1、連結串列反轉
2、快慢指標
連結串列反轉模板
ListNode cur = head.next; head.next = null; while (cur != null) { ListNode next = cur.next; cur.next = head; head = cur; cur = next; }
快慢指標模板
ListNode slow = head; ListNode fast= head; ListNode prev = slow; while(fast != null && fast.next != null){ prev =slow; slow = slow.next; fast = fast.next.next; }
部分題目分類
1. 簡單題
1290 Convert Binary Number in a Linked List to Integer
237 Delete Node in a Linked List
1669 Merge In Between Linked List
2. 連結串列反轉
3. 快慢指標