摘要: ``` /** * 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 阅读全文
posted @ 2020-04-29 11:14 AAAmsl 阅读(95) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 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 阅读全文
posted @ 2020-04-29 11:13 AAAmsl 阅读(72) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 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); 阅读全文
posted @ 2020-04-29 11:12 AAAmsl 阅读(93) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 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 阅读全文
posted @ 2020-04-29 11:11 AAAmsl 阅读(60) 评论(0) 推荐(0) 编辑
摘要: ```/** * 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... 阅读全文
posted @ 2020-04-29 11:10 AAAmsl 阅读(70) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 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) 阅读全文
posted @ 2020-04-29 11:09 AAAmsl 阅读(68) 评论(0) 推荐(0) 编辑