Add Two Numbers as Linked Lists
Learn to add two numbers represented as linked lists — both reverse order (LeetCode 2) and forward order (LeetCode 445). Covers carry handling, different-length lists, and Python implementations with Big-O analysis.
17 posts · page 1 of 1
Learn to add two numbers represented as linked lists — both reverse order (LeetCode 2) and forward order (LeetCode 445). Covers carry handling, different-length lists, and Python implementations with Big-O analysis.
Learn two approaches to deep copy a linked list with random pointers — HashMap O(n) space and the interleaving O(1) space technique. Step-by-step walkthroughs with Python code and Big-O analysis.
Learn to flatten a multilevel doubly linked list (LeetCode 430) and flatten sorted linked lists. Covers iterative and recursive DFS approaches with Python implementations and Big-O analysis.
Master the top 15 linked list interview patterns — dummy node, fast-slow pointers, reversal, merge, partition, and more. Includes common mistakes, a time complexity cheatsheet, and a decision flowchart.
Learn three ways to check if a linked list is a palindrome — stack-based O(n) space, reverse-second-half O(1) space, and recursive. Step-by-step walkthroughs with Python code and Big-O analysis.
Master linked list partitioning — partition around a value (LeetCode 86), odd-even rearrangement (LeetCode 328), segregate 0s/1s/2s, with full Python implementations and Big-O analysis.
Master the two-pointer gap technique to remove the nth node from the end in a single pass. Covers the dummy node trick, edge cases like removing the head and single-node lists, with Python code and Big-O analysis.
Learn how to reorder a linked list by interleaving first and last nodes — find the middle, reverse the second half, and merge alternating. Full Python code, step-by-step walkthrough, and Big-O analysis.
Master linked list rotation by K positions, swap nodes in pairs, and swap Kth nodes from both ends — full Python implementations, step-by-step traces, and Big-O analysis.
Master doubly linked lists with prev/next pointers, insertion and deletion at any position, circular linked list variants, and real-world use cases like browser history.
Find where two linked lists intersect using the two-pointer technique, length difference method, and hash set — with Python implementations and complexity analysis.
Learn Floyd's tortoise and hare algorithm for cycle detection in linked lists — detect cycles, find the start, measure cycle length, with full Python code and proofs.
Master every linked list reversal pattern — iterative, recursive, reverse in groups of K, and reverse between positions m and n, with Python code and common pitfalls.
Learn to merge two sorted lists, merge K sorted lists with a heap, and implement merge sort on linked lists with full Python code and complexity analysis.
The core operations every linked list problem builds on — inserting at head/tail/middle, deleting by value, reversing iteratively and recursively, finding the middle, and detecting a cycle.
A practical introduction to linked lists — what a node is, singly vs doubly linked, head and tail, how arrays and linked lists differ, and a clean Python implementation you can build on.
Eight classic linked-list interview problems — reverse, detect cycle, merge sorted lists, remove Nth from end, cycle start, palindrome, add two numbers, and intersection — each with a worked Python solution.