摘要:
``` /** * 114. Flatten Binary Tree to Linked List * 1. Time:O(n) Space:O(logn) * 2. Time:O(n) Space:O(1) * 3. Time:O(n) Space:O(logn) */ // 1. Time:O(n) Space:O(logn) class Solution { public void flat 阅读全文
摘要:
``` /** * 110. Balanced Binary Tree * 1. Time:O(n) Space:O(logn) */ // 1. Time:O(n) Space:O(logn) class Solution { public boolean isBalanced(TreeNode root) { return helper(root)>=0; } public int helpe 阅读全文
摘要:
``` /** * 101. Symmetric Tree * 1. Time:O(n) Space:O(n) * 2. Time:O(n) Space:O(n) */ // 1. Time:O(n) Space:O(n) class Solution { public boolean isSymmetric(TreeNode root) { return isMirror(root,root); 阅读全文
摘要:
``` /** * 100. Same Tree * 1. Time:O(n) Space:O(n) * 2. Time:O(n) Space:O(n) */ // 1. Time:O(n) Space:O(n) class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { if(p==null && q==null) r 阅读全文
摘要:
```/** * 99. Recover Binary Search Tree * 1. Time:O(n) Space:O(logn) * 2. Time:O(n) Space:O(1) */// 1. Time:O(n) Space:O(logn)class Solution { TreeNode p1 = null; TreeNode p2 = null; T... 阅读全文
摘要:
``` /** * 103. Binary Tree Zigzag Level Order Traversal * 1. Time:O(n) Space:O(n) * 2. Time:O(n) Space:O(n) */ // 1. Time:O(n) Space:O(n) class Solution { public List> zigzagLevelOrder(TreeNode root) 阅读全文