124.Binary-Tree-Maximum-Path-Sum
124. Binary Tree Maximum Path Sum
题目地址
https://leetcode.com/problems/binary-tree-maximum-path-sum/
题目描述
代码
Approach #1 Recursion
Complexity Analysis
Time complexity : O(N) where
N
is number of nodes, since we visit each node not more than 2 times.Space complexity :O(log(N)). We have to keep a recursion stack of the size of the tree height, which is O(log(N)) for the binary tree.
Last updated