Problem context and objectives
Mission briefing
Archive pathfinder · Clues branch through a living archive
Explore only the branches that can still contain the answer: The Canopy Diameter.
Ignoring the parent-child rule turns a focused search into a full maze traversal.
How you win
- 1Recognize when Binary tree diameter matches the clues
- 2Keep this true after every move: height is the longest downward edge arm and diameter is the best two-arm path seen anywhere
- 3Reach the result within O(n) time and O(height) space
Rules and pressure
- Target cost: O(n) time and O(height) space
- State rule: height is the longest downward edge arm and diameter is the best two-arm path seen anywhere
Lesson 1 of 3
Treat left + right heights as the edge span through each node. Return 1 + the larger height to the parent.
Join two child heights to measure the through span.
Your call · At the root, left height is 2 and right height is 1. What is the through diameter?