摘要:
``` /** * 236. Lowest Common Ancestor of a Binary Tree * 1. Time:O(n) Space:O(h) * 2. Time:O(n) Space:O(n) */ // 1. Time:O(n) Space:O(h) class Solution { public TreeNode lowestCommonAncestor(TreeNode 阅读全文
摘要:
```/** * 129. Sum Root to Leaf Numbers * 1. Time:O(n) Space:O(logn) * 2. Time:O(n) Space:O(n) */// 1. Time:O(n) Space:O(logn)class Solution { public int sumNumbers(TreeNode root) { return... 阅读全文
摘要:
```/** * 124. Binary Tree Maximum Path Sum * 1. Time:O(n) Space:O(logn) */// 1. Time:O(n) Space:O(logn)class Solution { private int maxSum = Integer.MIN_VALUE; public int maxPathSum(Tr... 阅读全文
摘要:
``` /** * 113. Path Sum II * 1. Time:O(n) Space:O(n) */ // 1. Time:O(n) Space:O(n) class Solution { public List> pathSum(TreeNode root, int sum) { List> res = new ArrayList(); helper(root,sum,res,new 阅读全文