leetlog-by-chao.hashnode.devLeetCode 494. Target Sum — 0/1 Knapsack ReframedThis post solves LeetCode 494. Target Sum by converting it into a subset sum / 0-1 knapsack counting problem. Problem Summary You are given an array nums and a target.By placing '+' or '-' in front of each number, you create an expression such as: +...Dec 3, 2025·3 min read
leetlog-by-chao.hashnode.devLeetCode 1049 – Last Stone Weight II1. Problem Overview We are given an array stones[i] representing weights. Each turn: Pick two stones x ≤ y if x == y: both vanish else: new stone = y - x At most one stone remains.Return the smallest possible final weight. Example: Input: [2,7,...Dec 2, 2025·3 min read
chaodu.hashnode.devLeetCode 416 — Partition Equal Subset Sum (My Debug Log)This problem looks simple at first, but it actually teaches you one of the most important dynamic programming patterns:subset sum = 0/1 knapsack. Here is my complete debug journey: from wrong brute force → wrong greedy → correct DP. 1. First Attempt...Dec 1, 2025·4 min read
leetlog-by-chao.hashnode.devUnique Binary Search Trees (LeetCode 96): A Complete ExplanationThis article explains the correct dynamic programming solution for LeetCode 96: Unique Binary Search Trees.I also document a common mistake that many learners make, including myself: trying to derive dp[n] by inserting a new node into all BSTs of siz...Nov 28, 2025·6 min read
leetlog-by-chao.hashnode.devLeetCode Daily Log — Integer Breakhttps://leetcode.cn/problems/integer-break/ Date: 2025-11-28Difficulty: MediumTopics: Dynamic Programming, MathStatus: Solved 1. Problem Summary Given an integer n, split it into at least two positive integers such that the product of these integers...Nov 28, 2025·4 min read