KarmaCoder Day 4 LC24/19/02.07/142
1️⃣ Swap nodes in pairs Link: lc24
- Draw the next directions can be straightforward.
2️⃣ Remove Nth node from end of list
- Two pointers, one moves first by n steps, then both move until the first one moves to the last node, then delete the node the second pointer is located at.
3️⃣ Intersection of two linked list
- Find the length difference of two lists and move the longer list pointer points to the same length position.
- Move pointers on both lists together until they intersect.
4️⃣ Linked List Cyle II
- Fast and slow two pointers with step size of 2 and 1, respectively, the distance between the head and the cycle begin is equal to the distance between the intersection and the cycle begin.
- code is difficult, the key is to find out the above pattern.