Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Maximum Path Sum in Tree

HardPython00:00
I
Practice interviewer
Your interviewer
In session
I
Interviewer

Welcome to the Python screen.

The question is on your right: Maximum Path Sum in Tree. Read through the requirements first.

Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?

You need to log in / sign up to run or submit.

Problem

Given the root of a binary tree, return the maximum sum of any path. A path may start and end at any nodes, must follow parent-child edges, and cannot revisit a node.

Constraints

  • 1 <= number of nodes <= 3 * 10^4
  • -1000 <= node value <= 1000
  • The input is a valid binary tree
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output