Binary Search

March 18, 2026 · 0 min · map[name:Jeanphilo]

LeetCode 146: LRU Cache Design with O(1) Hash Map + Doubly Linked List

Subtitle / Summary This is not a memorization question. It is core cache-engineering practice: satisfy fast lookup and least-recently-used eviction at the same time, both in constant average time. We derive the optimal structure from naive approaches and provide runnable implementations. Reading time: 14-18 min Tags: LRU, hash map, doubly linked list, system design SEO keywords: LRU Cache, LeetCode 146, hash map, doubly linked list, O(1) Meta description: Build an LRU cache with hash map + doubly linked list to achieve O(1) average get/put, with engineering use cases, pitfalls, and six-language implementations. A — Algorithm (Problem & Algorithm) Problem Restatement Design and implement LRUCache: ...

February 12, 2026 · 14 min · map[name:Jeanphilo]

LeetCode 19: Remove Nth Node From End of List (One-pass Two Pointers) ACERS Guide

Subtitle / Summary The hard part is not deletion itself, but locating the predecessor of the nth node from the end in a singly linked list. This article derives the one-pass two-pointer solution from simpler baselines and explains correctness, boundaries, and engineering transfer. Reading time: 12-15 min Tags: linked list, two pointers, interview high frequency SEO keywords: LeetCode 19, Remove Nth Node From End of List, linked list, fast/slow pointers, dummy node Meta description: A complete ACERS walkthrough for removing the nth node from the end: from brute force to one-pass two pointers, with complexity, pitfalls, engineering scenarios, and Python/C/C++/Go/Rust/JS implementations. Target Readers Beginners building a stable template for linked-list interview problems Developers who know fast/slow pointers but still make boundary mistakes Backend/system engineers who want to transfer problem-solving templates to chain-structured data in production Background / Motivation “Remove the nth node from the end” is a classic medium-level linked-list problem. The challenge is usually not the delete operation itself, but: ...

February 12, 2026 · 12 min · map[name:Jeanphilo]

LeetCode 138: Copy List with Random Pointer — A Complete Deep-Copy Breakdown

Subtitle / Abstract The real challenge in this problem is not traversing the list, but correctly cloning the cross-node reference relationships created by random pointers. This article moves from naive intuition to a hash-mapping solution, and explains why it is stable, maintainable, and practical in real engineering. Estimated reading time: 12–16 minutes Tags: Linked List, Deep Copy, Hash Table, Random Pointer SEO keywords: LeetCode 138, Copy List with Random Pointer, random list copy, deep copy, hash mapping Meta description: Perform deep copy of a random-pointer linked list via two passes plus a mapping table, with correctness, complexity, engineering practice, and six-language implementations. A — Algorithm (Problem and Algorithm) Problem Restatement Given a linked list of length n, each node has: ...

February 11, 2026 · 15 min · map[name:Jeanphilo]

LeetCode 2: Add Two Numbers from Naive to Optimal Carry Simulation

Subtitle / Summary This problem is just grade-school addition on a linked list: add one digit at a time, propagate carry, and append one final node if carry remains after both lists end. We move from naive ideas to the optimal one-pass solution, then map it to real engineering scenarios. Reading time: 12-15 min Tags: linked list, carry, simulation, LeetCode 2 SEO keywords: Add Two Numbers, LeetCode 2, reverse-order list, carry, dummy node Meta description: Use dummy + tail + carry to sum two reverse-order linked lists in O(max(m,n)) time, with common pitfalls, engineering analogies, and six-language runnable implementations. A — Algorithm (Problem & Algorithm) Problem Restatement You are given two non-empty linked lists representing two non-negative integers. Digits are stored in reverse order, and each node stores one digit. Return their sum as a linked list in the same reverse order. Except for number 0, the input numbers do not have leading zeros. ...

February 11, 2026 · 14 min · map[name:Jeanphilo]

Hot100: Sort List Linked-List Merge Sort ACERS Guide

Subtitle / Summary LeetCode 148 is not about whether you can sort; it is about choosing the right sorting strategy for linked-list constraints. For singly linked lists, merge sort fits naturally: split by middle, sort recursively, merge linearly. Reading time: 12-16 min Tags: Hot100, linked list, merge sort, divide and conquer SEO keywords: Sort List, linked list merge sort, LeetCode 148, Hot100 Meta description: A practical ACERS guide for LeetCode 148 with derivation, complexity analysis, engineering mappings, and runnable code in multiple languages. A - Algorithm (Problem and Algorithm) Problem Restatement Given the head of a linked list head, sort it in ascending order and return the sorted list. Required time complexity: O(n log n). ...

February 10, 2026 · 12 min · map[name:Jeanphilo]

Hot100: Merge K Sorted Lists Divide-and-Conquer O(N log k) ACERS Guide

Subtitle / Summary LeetCode 23 is a k-way merge problem, not just repeating LeetCode 21 in a loop. This ACERS guide derives the optimal structure, explains tradeoffs between divide-and-conquer and min-heap, and provides runnable implementations in multiple languages. Reading time: 12-16 min Tags: Hot100, linked list, divide and conquer, merge SEO keywords: Merge K Sorted Lists, LeetCode 23, divide and conquer, O(N log k), Hot100 Meta description: A full ACERS explanation of Merge K Sorted Lists from naive ideas to O(N log k) divide-and-conquer, with engineering mapping and multi-language code. A - Algorithm (Problem and Algorithm) Problem Restatement Given an array lists of k sorted linked lists, merge them into one sorted linked list and return it. ...

February 10, 2026 · 14 min · map[name:Jeanphilo]

Hot100: Linked List Cycle II Floyd Detection + Entry Localization ACERS Guide

Subtitle / Summary LeetCode 142 upgrades cycle detection into cycle entry localization. The robust template is Floyd: first detect a meeting inside the cycle, then reset one pointer to head and move both by one step; the next meeting node is the cycle entry. Reading time: 12-16 min Tags: Hot100, linked list, fast slow pointers, Floyd SEO keywords: Linked List Cycle II, cycle entry, Floyd, fast slow pointers, O(1) space, LeetCode 142, Hot100 Meta description: Floyd cycle detection + entry localization with proof intuition, engineering mapping, and runnable multi-language implementations in O(n) time and O(1) extra space. A - Algorithm (Problem and Algorithm) Problem Restatement Given head of a singly linked list, return the node where the cycle begins. If there is no cycle, return null. ...

February 10, 2026 · 12 min · map[name:Jeanphilo]

Hot100: Merge Two Sorted Lists Sentinel Two-Pointer Merge ACERS Guide

Subtitle / Summary This problem is the linked-list version of merge-sort’s merge step. Use a sentinel node plus two pointers to splice nodes in ascending order in O(m+n), without rebuilding the list. Reading time: 10-12 min Tags: Hot100, linked list, merge, two pointers SEO keywords: Merge Two Sorted Lists, sentinel node, linked list merge, LeetCode 21, Hot100 Meta description: A complete ACERS guide for LeetCode 21 with derivation, correctness invariants, pitfalls, and runnable multi-language code. A - Algorithm (Problem and Algorithm) Problem Restatement Given heads list1 and list2 of two sorted linked lists, merge them into one sorted linked list and return its head. The merged list should be formed by splicing together nodes from the original lists. ...

February 10, 2026 · 12 min · map[name:Jeanphilo]

Hot100: First Missing Positive In-Place Index Placement ACERS Guide

Subtitle / Summary First Missing Positive is a classic in-place indexing problem. Place each valid value x into slot x-1, then scan for the first mismatch. This ACERS guide explains the derivation, invariant, pitfalls, and production-style transfer. Reading time: 12-15 min Tags: Hot100, array, in-place hashing SEO keywords: First Missing Positive, in-place hashing, index mapping, O(n), Hot100, LeetCode 41 Meta description: O(n)/O(1) solution for First Missing Positive using in-place index placement, with complexity analysis, engineering scenarios, and runnable multi-language code. Target Readers Hot100 learners building stable array templates Intermediate developers who want to master in-place indexing techniques Engineers who need linear-time, constant-space array normalization Background / Motivation “Find the smallest missing positive” is fundamentally a placement problem. ...

February 10, 2026 · 10 min · map[name:Jeanphilo]

Hot100: Reverse Nodes in k-Group Group-Wise In-Place ACERS Guide

Subtitle / Summary LeetCode 25 is the upgrade path from 206 (full reversal) and 92 (interval reversal): split by groups, reverse inside each full group, reconnect safely, and keep the last incomplete group unchanged. Reading time: 14-18 min Tags: Hot100, linked list, group reversal, dummy node SEO keywords: Reverse Nodes in k-Group, group reversal, LeetCode 25, Hot100 Meta description: In-place k-group linked-list reversal with dummy-node anchoring and safe reconnection, including pitfalls, complexity, and runnable multi-language implementations. A - Algorithm (Problem and Algorithm) Problem Restatement Given the head of a linked list and an integer k, reverse nodes in groups of size k and return the modified head. If the number of remaining nodes is less than k, keep them in original order. You must modify pointers, not just node values. ...

February 10, 2026 · 13 min · map[name:Jeanphilo]