摘要: https://leetcode.com/problems/is-graph-bipartite/discuss/115487/Java-Clean-DFS-solution-with-Explanation 阅读全文
posted @ 2018-10-24 10:25 jasoncool1 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 1 //New 2 class Solution { 3 public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { 4 if(root == null) return null; 5 if(root.val == p.val || root.... 阅读全文
posted @ 2018-10-24 08:54 jasoncool1 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 1 //可以任意节点开始left+right 所以dfs的时候要每个节点都计算一下 2 class Solution { 3 int max = Integer.MIN_VALUE; 4 public int diameterOfBinaryTree(TreeNode root) { 5 if(root == null) return 0; 6 ... 阅读全文
posted @ 2018-10-24 04:36 jasoncool1 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 int max = Integer.MIN_VALUE; 3 public int maxPathSum(TreeNode root) { 4 if(root == null) return 0; 5 if(root.left == null && root.right == null) retu... 阅读全文
posted @ 2018-10-24 03:54 jasoncool1 阅读(95) 评论(0) 推荐(0) 编辑