摘要:
``` /** * 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 阅读全文
摘要:
``` /** * 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 阅读全文
摘要:
``` /** * 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 阅读全文
摘要:
```/** * 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... 阅读全文