摘要: 1 class Solution { 2 public void connect(TreeLinkNode root) { 3 if(root == null) return; 4 Queue queue = new LinkedList(); 5 queue.offer(root); 6 int size = ... 阅读全文
posted @ 2018-09-21 23:49 jasoncool1 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public void connect(TreeLinkNode root) { 3 if(root == null) return; 4 Queue queue = new LinkedList(); 5 queue.offer(root); 6 int size = ... 阅读全文
posted @ 2018-09-21 23:44 jasoncool1 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 把左边=null, 把最左边遍历到null 保证已经flatten 然后再弄右边 然后把root.right跟左边连接,再把右边连接到root.right的最下面 https://leetcode.com/problems/flatten-binary-tree-to-linked-list/dis 阅读全文
posted @ 2018-09-21 23:03 jasoncool1 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 List> res = new ArrayList(); 3 public List> pathSum(TreeNode root, int sum) { 4 if(root == null) return res; 5 backtrack(root, sum, new ArrayList());... 阅读全文
posted @ 2018-09-21 09:11 jasoncool1 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 只有在两个子节点都是null的叶节点才有可能符合条件\ 阅读全文
posted @ 2018-09-21 08:46 jasoncool1 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 注意只有一个子节点的情况,分开讨论 阅读全文
posted @ 2018-09-21 08:02 jasoncool1 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public boolean isBalanced(TreeNode root) { 3 if(root == null) return true; 4 return(isBalanced(root.left) && isBalanced(root.right) && Math.abs(dfs(root.l... 阅读全文
posted @ 2018-09-21 07:49 jasoncool1 阅读(77) 评论(0) 推荐(0) 编辑