<?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>Dfs on Jeanphilo Blog</title><link>https://jeanphilogong.github.io/jeanblog/tags/dfs/</link><description>Recent content in Dfs on Jeanphilo Blog</description><generator>Hugo -- 0.168.0</generator><language>en-us</language><lastBuildDate>Fri, 29 May 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://jeanphilogong.github.io/jeanblog/tags/dfs/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 547: Number of Provinces, Turn an Adjacency Matrix into Connected Components</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/547-number-of-provinces/</link><pubDate>Fri, 29 May 2026 00:00:00 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/547-number-of-provinces/</guid><description>Turn LeetCode 547 Number of Provinces from direct connections in an adjacency matrix into connected component counting, then derive DFS, BFS, and Union Find solutions step by step.</description></item><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>Hot100: Binary Tree Maximum Path Sum (Tree DP / Single-Side Gain ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/124-binary-tree-maximum-path-sum/</link><pubDate>Mon, 20 Apr 2026 10:01:46 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/124-binary-tree-maximum-path-sum/</guid><description>A practical guide to LeetCode 124 covering the key design split: return only the best single-side gain upward, while using the full path through the current node to update a global answer.</description></item><item><title>Hot100: Diameter of Binary Tree (Tree DP / Height Return ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/543-diameter-of-binary-tree/</link><pubDate>Sun, 19 Apr 2026 15:51:55 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/543-diameter-of-binary-tree/</guid><description>A practical guide to LeetCode 543 covering the key split between returned height and global diameter updates, plus engineering mappings and runnable multi-language implementations.</description></item><item><title>Hot100: Lowest Common Ancestor of a Binary Tree (Postorder Return Semantics ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/236-lowest-common-ancestor-of-a-binary-tree/</link><pubDate>Sun, 19 Apr 2026 15:51:55 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/236-lowest-common-ancestor-of-a-binary-tree/</guid><description>A practical guide to LeetCode 236 covering the return-value meaning in postorder recursion, when the current node becomes the answer, and why a node can be its own ancestor.</description></item><item><title>Hot100: Validate Binary Search Tree (Range Constraints / Inorder ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/98-validate-binary-search-tree/</link><pubDate>Sun, 19 Apr 2026 15:13:19 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/98-validate-binary-search-tree/</guid><description>A practical guide to LeetCode 98 covering ancestor range constraints, why parent-only checks fail, and two stable solutions: recursive bounds and inorder validation.</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><item><title>LeetCode 133: Clone Graph Hash Map + DFS/BFS ACERS Guide</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/133-clone-graph/</link><pubDate>Thu, 19 Mar 2026 13:18:26 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/133-clone-graph/</guid><description>Clone a connected undirected graph by mapping original nodes to cloned nodes, with DFS and BFS variants, cycle handling, correctness reasoning, and runnable implementations in six languages.</description></item><item><title>Hot100: Binary Tree Level Order Traversal (BFS / DFS ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/102-binary-tree-level-order-traversal/</link><pubDate>Mon, 16 Mar 2026 13:00:56 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/102-binary-tree-level-order-traversal/</guid><description>A practical guide to LeetCode 102 covering level-by-level BFS, level-size boundaries, DFS depth buckets, and runnable multi-language implementations.</description></item><item><title>Hot100: Symmetric Tree (Mirror Recursion / BFS ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/101-symmetric-tree/</link><pubDate>Mon, 16 Mar 2026 13:00:55 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/101-symmetric-tree/</guid><description>A practical guide to LeetCode 101 covering mirror recursion, pairwise BFS checks, symmetry contracts, and runnable multi-language implementations.</description></item><item><title>Hot100: Same Tree (Synchronous Recursion / BFS ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/100-same-tree/</link><pubDate>Mon, 16 Mar 2026 13:00:54 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/100-same-tree/</guid><description>A practical guide to LeetCode 100 covering synchronous recursion, pairwise BFS validation, structural equivalence, and runnable multi-language implementations.</description></item><item><title>Hot100: Maximum Depth of Binary Tree (DFS / BFS ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/104-maximum-depth-of-binary-tree/</link><pubDate>Fri, 06 Mar 2026 17:58:22 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/104-maximum-depth-of-binary-tree/</guid><description>A practical guide to LeetCode 104 covering the depth definition, recursive DFS, level-order BFS, engineering mappings, and runnable multi-language implementations.</description></item><item><title>Hot100: Binary Tree Inorder Traversal (Recursion / Stack ACERS Guide)</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/94-binary-tree-inorder-traversal/</link><pubDate>Fri, 06 Mar 2026 17:58:21 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/hot100/binary-tree/94-binary-tree-inorder-traversal/</guid><description>A practical guide to LeetCode 94 covering left-root-right traversal, recursion, explicit stacks, engineering mappings, and runnable multi-language implementations.</description></item><item><title>Connected Components and Strongly Connected Components: Tarjan / Kosaraju ACERS Engineering Analysis</title><link>https://jeanphilogong.github.io/jeanblog/dev/algorithm/graph/40-connected-components-and-scc-tarjan-kosaraju/</link><pubDate>Mon, 09 Feb 2026 09:50:22 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/dev/algorithm/graph/40-connected-components-and-scc-tarjan-kosaraju/</guid><description>A systematic guide to undirected Connected Components and directed SCCs, with emphasis on Tarjan (common in production) and Kosaraju, mapped to graph-database scenarios such as community pre-grouping, subgraph splitting, and partition hints.</description></item><item><title>BFS / DFS Engineering Primer: k-hop Queries, Subgraph Extraction, and Path Existence ACERS Breakdown</title><link>https://jeanphilogong.github.io/jeanblog/dev/algorithm/graph/10-bfs-dfs-k-hop-subgraph-path-existence/</link><pubDate>Mon, 09 Feb 2026 09:44:11 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/dev/algorithm/graph/10-bfs-dfs-k-hop-subgraph-path-existence/</guid><description>Centered on three high-frequency graph tasks (k-hop query, subgraph extraction, and path existence), this article explains practical BFS/DFS iteration templates, early-stop pruning, and visited bitmap/bloom choices with runnable multi-language implementations.</description></item><item><title>Path Sum III: Prefix Sum + Hash Map Counting Downward Paths (LeetCode 437) ACERS Guide</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/437-path-sum-iii/</link><pubDate>Wed, 04 Feb 2026 16:02:26 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/437-path-sum-iii/</guid><description>Count downward paths in a binary tree whose sum equals targetSum in O(n) using prefix sums and a frequency hash map, with derivation, engineering mapping, and multi-language implementations.</description></item></channel></rss>