Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Tree problems in depth

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Tree problems in depth

Binary Tree Maximum Path Sum

advancedlayer I2 · Tree problems in depth5 tests

A path here is any sequence of connected nodes — each consecutive pair joined by an edge — visiting no node twice. It does not have to touch the root. Return the largest possible sum of the values along such a path.

  • The tree has at least one node, and a single node is a valid path
  • Values may be negative, so the answer can be negative
  • A path bends at most once: it can come up one subtree and go down the other

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen