摘要: ```/** * 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) 编辑
摘要: ```/** * 173. Binary Search Tree Iterator * 1. Time:O() Space:O() * 2. Time:O() Space:O() */// 1. Time:O() Space:O()class BSTIterator { ArrayList res; int index; public BSTIterator(Tre... 阅读全文
posted @ 2020-04-28 13:58 AAAmsl 阅读(66) 评论(0) 推荐(0) 编辑
摘要: ```/** * 226. Invert Binary 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 TreeNode invertTree(TreeNode root) { if(root==null... 阅读全文
posted @ 2020-04-28 13:57 AAAmsl 阅读(65) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 199. Binary Tree Right Side View * 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 rightSideView(TreeNode root) { List res = new 阅读全文
posted @ 2020-04-28 13:56 AAAmsl 阅读(70) 评论(0) 推荐(0) 编辑
摘要: ```/** * 107. Binary Tree Level Order Traversal II * 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> levelOrderBottom(TreeNode root) {... 阅读全文
posted @ 2020-04-28 13:54 AAAmsl 阅读(64) 评论(0) 推荐(0) 编辑
摘要: ``` /** * 102. Binary Tree 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> levelOrder(TreeNode root) { List> res = 阅读全文
posted @ 2020-04-27 12:07 AAAmsl 阅读(65) 评论(0) 推荐(0) 编辑
摘要: ```/** * 145. Binary Tree Postorder Traversal * 1. Time:O(n) Space:O(n) * 2. Time:O(n) Space:O(n) * 3. Time:O(n) Space:O(n) * 4. Time:O(n) Space:O(1) */// 1. Time:O(n) Space:O(n)class Solution { ... 阅读全文
posted @ 2020-04-27 12:05 AAAmsl 阅读(62) 评论(0) 推荐(0) 编辑
摘要: ```/** * 94. Binary Tree Inorder Traversal * 1. Time:O(n) Space:O(n) * 2. Time:O(n) Space:O(n) * 3. Time:O(n) Space:O(1) */// 1. Time:O(n) Space:O(n)class Solution { public List inorderTraversa... 阅读全文
posted @ 2020-04-27 12:04 AAAmsl 阅读(75) 评论(0) 推荐(0) 编辑
摘要: ```/** * 144. Binary Tree Preorder Traversal * 1. Time:O(n) Space:O(n) * 2. Time:O(n) Space:O(n) * 3. Time:O(n) Space:O(n) * 4. Time:O(n) Space:O(1) */// 1. Time:O(n) Space:O(n)class Solution { ... 阅读全文
posted @ 2020-04-27 12:03 AAAmsl 阅读(54) 评论(0) 推荐(0) 编辑