Maximum Value in a Binary Tree

Given the root node root of a non-empty binary tree, return the maximum value among all nodes in the tree. Node values may be negative.

Definition:

class TreeNode:
    def __init__(self,...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: