Binary Tree Maximum Path Sum: The Hard Version of Diameter
Any-to-any max path — clamp negative arms to zero and track the bend. Python solution and complexity analysis for the DFS interview pattern.
Tag
Articles tagged Tree DFS on The Augmented Dev.
11 articles
Any-to-any max path — clamp negative arms to zero and track the bend. Python solution and complexity analysis for the DFS interview pattern.
Return one thing, track another — the two-quantity DFS shape. Python solution and complexity analysis for the DFS interview pattern.
The famous swap-children recursion — and its iterative twin. Python solution and complexity analysis for the DFS interview pattern.
Return what you found — the split node emerges from the recursion. Python solution and complexity analysis for the DFS interview pattern.
The four-line recursion that teaches the subtree-answer discipline. Python solution and complexity analysis for the DFS interview pattern.
The most-asked grid question — sink each island as you count it. Python solution and complexity analysis for the DFS interview pattern.
Collect all matching root-to-leaf paths — append, recurse, pop. Python solution and complexity analysis for the DFS interview pattern.
Root-to-leaf target sums — subtract as you descend, decide at leaves. Python solution and complexity analysis for the DFS interview pattern.
Walk two trees in lockstep — the base-case ordering does the work. Python solution and complexity analysis for the DFS interview pattern.
Check mirror symmetry by walking outer-outer and inner-inner pairs. Python solution and complexity analysis for the DFS interview pattern.
The local-check trap, defeated by passing (low, high) down the tree. Python solution and complexity analysis for the DFS interview pattern.