← [ BACK_TO_NOTES ]

Linked List Interview Patterns

Common linked list patterns intersection, reverse in k-group, palindrome, cycle entry

#algorithm #concept #growing #linked-list

[!info] related notes 算法面试题型 MOC

Linked List Interview Patterns

Intersection of Two Acyclic Lists

  • Let the longer list advance abs(lenA - lenB) steps first.
  • Then move both pointers together; the first equal node is the intersection.

Reverse Nodes in k-Group

  • Pattern: locate a k-sized block, reverse it, connect tail to next block.
  • Key: you need the previous block’s tail to reconnect.

Copy List with Random Pointer

  • Common patterns:
    • HashMap old->new.
    • Interleaving nodes (clone node inserted after original) then split.

Palindrome List

  • Fast/slow pointers find middle.
  • Reverse second half.
  • Compare two halves.
  • Optional: restore the list by reversing back.
// compare halves after reversing from mid
// (template only; adapt to your ListNode definition)

Cycle Entry Node

  • HashSet method: record visited nodes.
  • Floyd method:
    • First meet: fast and slow.
    • Then set one pointer to head, both move 1 step; next meet is the entry.
创建于 2026/3/16 更新于 2026/7/15
Digital Biome
Access

键盘导航

j / k / ↑ / ↓
选择对象
Enter / o
打开选择
/ 或 Ctrl+K
全站搜索
i / f / 1–4
筛选当前列表
g → h / l / p / t / a
首页 / 笔记 / 项目 / 工具 / About
r → 1–9
打开所选对象的关联
u
返回上一页
Esc
关闭浮层 / 取消命令;输入框内清空文本