LeetCode 198: House Robber, Deriving 1D DP from Rob or Skip

Problem Input and Output Input: an integer array nums nums[i] is the money in the i-th house Adjacent houses cannot both be robbed Output: return the maximum amount of money that can be robbed Constraints: 1 <= nums.length <= 100, 0 <= nums[i] <= 400 Examples Input: nums = [1,2,3,1] Output: 4 Explanation: rob indices 0 and 2, for 1 + 3 = 4 Input: nums = [2,7,9,3,1] Output: 12 Explanation: rob indices 0, 2, and 4, for 2 + 9 + 1 = 12 This article uses Python only and derives 1D DP from the conflict between two choices. ...

May 3, 2026 · 6 min · map[name:Jeanphilo]

LeetCode 78: Subsets, Derive the startIndex Backtracking Template

Problem Requirement Input / Output Input: nums, with 1 <= nums.length <= 10 Value range: -10 <= nums[i] <= 10 All elements in nums are distinct Output: return all possible subsets of nums Ordering: the result order does not matter, and subset element order is not the point Example Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] This tutorial builds one minimal Python solution. Start From the Search Tree for [1,2] The smallest branching example is: ...

May 3, 2026 · 6 min · map[name:Jeanphilo]

LeetCode 90: Subsets II, Derive Layer-Level Deduplication

Problem Requirement Input / Output Input: nums, with 1 <= nums.length <= 10 Value range: -10 <= nums[i] <= 10 nums may contain duplicates Output: return all unique subsets Ordering: the result order does not matter, but the same value sequence may appear only once Example Input: nums = [1,2,2] Output: [[],[1],[1,2],[1,2,2],[2],[2,2]] This tutorial starts with a correct but wasteful version, then derives sorting plus layer-level deduplication. Start From Duplicate Branches in [1,2,2] The smallest example that exposes the issue is: ...

May 3, 2026 · 6 min · map[name:Jeanphilo]

Hot100: Binary Tree Maximum Path Sum (Tree DP / Single-Side Gain ACERS Guide)

Subtitle / Summary The easiest way to get lost in LeetCode 124 is to make one recursive return value carry too much meaning. The stable design is to separate two roles: the recursion returns only the best single-side gain to the parent, while the full path through the current node is used to update the global maximum. Reading time: 12-15 min Tags: Hot100, binary tree, tree DP, DFS, postorder SEO keywords: Binary Tree Maximum Path Sum, tree DP, single-side gain, postorder, DFS, LeetCode 124 Meta description: Learn LeetCode 124 from the single-side gain invariant, global path update, and negative-branch pruning, with runnable multi-language implementations. A — Algorithm Problem Restatement A path in a binary tree is a sequence of nodes such that: ...

April 20, 2026 · 13 min · map[name:Jeanphilo]

Hot100: Binary Tree Right Side View (Level Order Last-Node Rule ACERS Guide)

Subtitle / Summary LeetCode 199 is not really about visual imagination. It is about translating a viewpoint problem into a level problem. Once you realize that the right side view is simply the last node of each level, the problem becomes a standard breadth-first traversal. Reading time: 10-13 min Tags: Hot100, binary tree, BFS, level order, queue SEO keywords: Binary Tree Right Side View, BFS, level order, queue, right-first DFS, LeetCode 199 Meta description: Learn LeetCode 199 from the core equivalence “right side view = last node of each level”, with step-by-step derivation, engineering mappings, and runnable multi-language implementations. A — Algorithm Problem Restatement Given the root root of a binary tree, imagine standing on its right side and return the values of the nodes you can see from top to bottom. ...

April 20, 2026 · 12 min · map[name:Jeanphilo]

Hot100: Construct Binary Tree from Preorder and Inorder Traversal (Indexed Divide-and-Conquer ACERS Guide)

Subtitle / Summary The key to LeetCode 105 is not memorizing that preorder and inorder can reconstruct a tree. It is understanding what each traversal contributes: preorder tells you the root, inorder tells you the left/right boundary. Once those roles are clear, the whole problem becomes a clean indexed divide-and-conquer. Reading time: 12-15 min Tags: Hot100, binary tree, divide and conquer, hash map, preorder SEO keywords: Construct Binary Tree from Preorder and Inorder Traversal, preorder, inorder, divide and conquer, hash map, LeetCode 105 Meta description: Learn LeetCode 105 from traversal roles, indexed recursion, and hash-map root lookup, with runnable multi-language implementations. A — Algorithm Problem Restatement Given the preorder traversal preorder and inorder traversal inorder of a binary tree, reconstruct the tree and return its root. ...

April 20, 2026 · 13 min · map[name:Jeanphilo]

Hot100: Convert Sorted Array to Binary Search Tree (Midpoint Divide-and-Conquer ACERS Guide)

Subtitle / Summary The key to LeetCode 108 is not recursion by itself. It is noticing that the problem wants two things at the same time: BST ordering and height balance. Once you read those two constraints together, “pick the middle element as the root” stops being a trick and becomes the natural construction rule. Reading time: 11-14 min Tags: Hot100, binary tree, BST, divide and conquer, recursion SEO keywords: Convert Sorted Array to Binary Search Tree, BST, balanced BST, divide and conquer, recursion, LeetCode 108 Meta description: Learn LeetCode 108 from the midpoint-construction idea, with step-by-step derivation, engineering mappings, and runnable multi-language implementations. A — Algorithm Problem Restatement Given an integer array nums sorted in strictly increasing order, convert it into a height-balanced binary search tree. ...

April 20, 2026 · 12 min · map[name:Jeanphilo]

Hot100: Flatten Binary Tree to Linked List (Reverse Preorder Rewiring ACERS Guide)

Subtitle / Summary The real difficulty of LeetCode 114 is not “flattening” a tree. It is rewiring pointers without destroying the structure you still need. Once you notice that the final linked list must follow preorder order, reverse preorder with a prev pointer becomes a very stable in-place solution. Reading time: 12-15 min Tags: Hot100, binary tree, preorder, in-place, recursion SEO keywords: Flatten Binary Tree to Linked List, preorder, in-place, reverse preorder, LeetCode 114 Meta description: Learn LeetCode 114 from preorder order and reverse-preorder rewiring, with step-by-step derivation, engineering mappings, and runnable multi-language implementations. A — Algorithm Problem Restatement Given the root root of a binary tree, flatten the tree into a linked list in place. ...

April 20, 2026 · 12 min · map[name:Jeanphilo]

Hot100: Kth Smallest Element in a BST (Inorder Counting / Early Stop ACERS Guide)

Subtitle / Summary LeetCode 230 is not really about tree traversal mechanics alone. It is about turning BST order into a useful query. Once you see that the k-th smallest value is simply the k-th node visited in inorder traversal, the problem becomes a very stable counting task. Reading time: 11-14 min Tags: Hot100, binary tree, BST, inorder traversal, stack SEO keywords: Kth Smallest Element in a BST, BST, inorder traversal, stack, LeetCode 230 Meta description: Learn LeetCode 230 from BST inorder ordering, explicit-stack counting, and early-stop traversal, with runnable multi-language implementations. A — Algorithm Problem Restatement Given the root root of a binary search tree and an integer k, return the k-th smallest value in the tree. ...

April 20, 2026 · 12 min · map[name:Jeanphilo]

Hot100: Add Two Numbers Linked-List Carry Simulation ACERS Guide

Subtitle / Summary LeetCode 2 is grade-school addition translated into a linked-list workflow. The only persistent state is the carry, and the only structural work is appending one new digit per round. Reading time: 12-15 min Tags: Hot100, linked list, carry, simulation SEO keywords: Add Two Numbers, linked-list carry, reverse order digits, LeetCode 2, Hot100 Meta description: A derivation-first ACERS guide to LeetCode 2 with carry propagation, dummy node construction, engineering mapping, and runnable multi-language code. A - Algorithm (Problem and Algorithm) Problem Restatement You are given two non-empty linked lists l1 and l2. Each list stores a non-negative integer in reverse order, and each node contains one digit. Add the two integers and return the sum as a linked list in the same reverse order. ...

April 20, 2026 · 17 min · map[name:Jeanphilo]