摘要: ``` /** * 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 阅读全文
posted @ 2020-05-09 09:34 AAAmsl 阅读(84) 评论(0) 推荐(0) 编辑
摘要: ```/** * 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... 阅读全文
posted @ 2020-05-09 09:31 AAAmsl 阅读(60) 评论(0) 推荐(0) 编辑
摘要: ```/** * 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... 阅读全文
posted @ 2020-05-09 09:29 AAAmsl 阅读(76) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 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 阅读全文
posted @ 2020-05-09 09:27 AAAmsl 阅读(62) 评论(0) 推荐(0) 编辑