摘要:
https://leetcode.com/problems/is-graph-bipartite/discuss/115487/Java-Clean-DFS-solution-with-Explanation 阅读全文
摘要:
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.... 阅读全文
摘要:
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 ... 阅读全文
摘要:
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... 阅读全文