<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Backtracking on Jeanphilo Blog</title><link>https://jeanphilogong.github.io/jeanblog/tags/backtracking/</link><description>Recent content in Backtracking on Jeanphilo Blog</description><generator>Hugo -- 0.168.0</generator><language>en-us</language><lastBuildDate>Sun, 03 May 2026 14:25:07 +0800</lastBuildDate><atom:link href="https://jeanphilogong.github.io/jeanblog/tags/backtracking/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 78: Subsets, Derive the startIndex Backtracking Template</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/78-subsets/</link><pubDate>Sun, 03 May 2026 14:25:07 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/78-subsets/</guid><description>&lt;h2 id="problem-requirement"&gt;Problem Requirement&lt;/h2&gt;
&lt;h3 id="input--output"&gt;Input / Output&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Input: &lt;code&gt;nums&lt;/code&gt;, with &lt;code&gt;1 &amp;lt;= nums.length &amp;lt;= 10&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Value range: &lt;code&gt;-10 &amp;lt;= nums[i] &amp;lt;= 10&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;All elements in &lt;code&gt;nums&lt;/code&gt; are distinct&lt;/li&gt;
&lt;li&gt;Output: return all possible subsets of &lt;code&gt;nums&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Ordering: the result order does not matter, and subset element order is not the point&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="example"&gt;Example&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Input: nums = [1,2,3]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This tutorial builds one minimal Python solution.&lt;/p&gt;
&lt;h2 id="start-from-the-search-tree-for-12"&gt;Start From the Search Tree for &lt;code&gt;[1,2]&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The smallest branching example is:&lt;/p&gt;</description></item><item><title>LeetCode 90: Subsets II, Derive Layer-Level Deduplication</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/90-subsets-ii/</link><pubDate>Sun, 03 May 2026 14:25:07 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/90-subsets-ii/</guid><description>&lt;h2 id="problem-requirement"&gt;Problem Requirement&lt;/h2&gt;
&lt;h3 id="input--output"&gt;Input / Output&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Input: &lt;code&gt;nums&lt;/code&gt;, with &lt;code&gt;1 &amp;lt;= nums.length &amp;lt;= 10&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Value range: &lt;code&gt;-10 &amp;lt;= nums[i] &amp;lt;= 10&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nums&lt;/code&gt; may contain duplicates&lt;/li&gt;
&lt;li&gt;Output: return all unique subsets&lt;/li&gt;
&lt;li&gt;Ordering: the result order does not matter, but the same value sequence may appear only once&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="example"&gt;Example&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Input: nums = [1,2,2]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Output: [[],[1],[1,2],[1,2,2],[2],[2,2]]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This tutorial starts with a correct but wasteful version, then derives sorting plus layer-level deduplication.&lt;/p&gt;
&lt;h2 id="start-from-duplicate-branches-in-122"&gt;Start From Duplicate Branches in &lt;code&gt;[1,2,2]&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The smallest example that exposes the issue is:&lt;/p&gt;</description></item><item><title>Hot100: N-Queens Incremental Build Tutorial</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/51-n-queens/</link><pubDate>Sun, 19 Apr 2026 14:49:56 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/51-n-queens/</guid><description>A teaching-first incremental tutorial for LeetCode 51 that grows the N-Queens solution from a tiny example and a minimal DFS into column and diagonal state optimization.</description></item><item><title>Hot100: Palindrome Partitioning (Backtracking / Palindrome Table ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/131-palindrome-partitioning/</link><pubDate>Sun, 19 Apr 2026 14:49:56 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/131-palindrome-partitioning/</guid><description>A practical guide to LeetCode 131 that builds string-partition backtracking from scratch and shows why a palindrome table makes the search cleaner and more reusable.</description></item><item><title>LeetCode 216: Combination Sum III (Backtracking / Fixed-Length Search ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/216-combination-sum-iii/</link><pubDate>Fri, 17 Apr 2026 14:31:12 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/216-combination-sum-iii/</guid><description>Learn LeetCode 216 by deriving fixed-length combination search, use-once recursion, and bounded 1..9 pruning from the problem itself.</description></item><item><title>LeetCode 40: Combination Sum II (Backtracking / Same-Layer Dedup ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/40-combination-sum-ii/</link><pubDate>Fri, 17 Apr 2026 14:31:10 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/40-combination-sum-ii/</guid><description>Learn LeetCode 40 by deriving same-layer duplicate skipping, use-once recursion, and sorted pruning from the problem itself.</description></item><item><title>Hot100: Combination Sum (Backtracking / Pruning ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/39-combination-sum/</link><pubDate>Wed, 08 Apr 2026 16:22:57 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/39-combination-sum/</guid><description>A practical guide to LeetCode 39 that builds combination backtracking from scratch, explains remain-based state, and shows why sorting makes pruning safe.</description></item><item><title>Hot100: Permutations (used[] Backtracking ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/46-permutations/</link><pubDate>Fri, 03 Apr 2026 17:54:22 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/backtracking/46-permutations/</guid><description>A practical guide to LeetCode 46 covering used[] state tracking, leaf-only collection, and runnable multi-language implementations.</description></item></channel></rss>