Taking Smart Notes With Org-mode
  • About
  • Articles
  • Notes
  • Search
Home » Notes

Linked List

March 11, 2022 · 1 min · Gray King
  • tags: Data Structures

Links to this note


    Cycle detection

    tags: Algorithm,Linked List,Fast & Slow Pointers source: https://en.wikipedia.org/wiki/Cycle%5Fdetection Floyd’s tortoise and hare With two pointers: tortoise move slow: move 1 step in each loop. hare move fast: move 2 steps in each loop. If there is a circle existed, tortoise and hare will meet eventually in the circle. Now both tortoise and hare are in the circle, how to figure out the beginning of the circle? We put tortoise back to the beginning they both started. Such as, the first element of the linked list. Then we move both tortoise and hare step by step, they will meet in the beginning of the circle.

    March 29, 2022 · 1 min · Gray King

    LeetCode101: 445. Add Two Numbers II

    tags: Linked List,Stack, LeetCode101,2. Add Two Numbers 两数之和的进阶版,位高的数字在链表的头部,常规解法是通过「栈」进行反转链表,然后回退到2. Add Two Numbers的解法。

    March 11, 2022 · 1 min · Gray King

    LeetCode101: 2. Add Two Numbers

    tags: Linked List, LeetCode101 正常的「链表」遍历操作,需要注意的就是不要在末尾忘记处理进位,如果 carry 大于 0 需要追加到结果链表末尾。

    March 11, 2022 · 1 min · Gray King
© 2025 Taking Smart Notes With Org-mode · Powered by Hugo & PaperMod