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]