Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Maximum Tree Path

Learn
Play
Prove
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 Maximum Tree Path.

Ignoring the parent-child rule turns a focused search into a full maze traversal.

How you win

  1. 1Recognize when Binary tree maximum path sum matches the clues
  2. 2Keep this true after every move: gain(node) is the best nonnegative-extended path starting at node, while answer is the best complete path seen
  3. 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: gain(node) is the best nonnegative-extended path starting at node, while answer is the best complete path seen
Lesson 1 of 3

Score a complete path with both positive arms at every node, then return only the better single arm to the parent.

Separate the two-arm score from the one-arm return at one node.

Your call · At node 20, what are the complete-path score and upward gain?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead