摘要: ``` /** * 112. Path Sum * 1. Time:O(n) Space:O(h) * 2. Time:O(n) Space:O(h) */ // 1. Time:O(n) Space:O(h) class Solution { public boolean hasPathSum(TreeNode root, int sum) { if(root==null) return fal 阅读全文
posted @ 2020-05-08 11:12 AAAmsl 阅读(65) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 111. Minimum Depth of Binary Tree * 1. Time:O(n) Space:O(h) * 2. Time:O(n) Space:O(h) */ // 1. Time:O(n) Space:O(h) class Solution { public int minDepth(TreeNode root) { if(root==null) retur 阅读全文
posted @ 2020-05-08 11:10 AAAmsl 阅读(90) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 104. Maximum Depth of Binary Tree * 1. Time:O(n) Space:O(h) * 2. Time:O(n) Space:O(h) * 3. Time:O(n) Space:O(h) */ // 1. Time:O(n) Space:O(h) class Solution { public int maxDepth(TreeNode ro 阅读全文
posted @ 2020-05-08 11:08 AAAmsl 阅读(64) 评论(0) 推荐(0) 编辑
摘要: ```/** * 230. Kth Smallest Element in a BST * 1. Time:O(n) Space:O(n) * 2. Time:O(h+k) Space:O(h+k) * 3. Time:O(h+k) Space:O(h+k) */// 1. Time:O(n) Space:O(n)class Solution { public int kthSmal... 阅读全文
posted @ 2020-05-08 11:07 AAAmsl 阅读(49) 评论(0) 推荐(0) 编辑