上一页 1 2 3 4 5 6 7 8 9 10 ··· 22 下一页
摘要: 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) 编辑
摘要: 1 public class Solution extends VersionControl { 2 public int firstBadVersion(int n) { 3 if(n == 1) return 1; 4 int lo = 1, hi = n; 5 while(lo < hi){ 6 i... 阅读全文
posted @ 2018-10-23 22:15 jasoncool1 阅读(78) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/valid-number/discuss/23738/Clear-Java-solution-with-ifs 阅读全文
posted @ 2018-10-23 11:31 jasoncool1 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 1 //New presum 2 class Solution { 3 public boolean checkSubarraySum(int[] nums, int k) { 4 if(k == 0){ 5 for(int i = 1; i list = new ArrayList(); 31 for(int i = ... 阅读全文
posted @ 2018-10-23 05:27 jasoncool1 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1 public class BSTIterator { 2 Queue queue; 3 public void build(TreeNode root){ 4 if(root == null) return; 5 build(root.left); 6 queue.offer(root.val); 7 ... 阅读全文
posted @ 2018-10-23 01:28 jasoncool1 阅读(81) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/discuss/108231/C++Java-DP-with-explanation-O(n) 阅读全文
posted @ 2018-10-23 01:08 jasoncool1 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 用Trie, dp会TLE 阅读全文
posted @ 2018-10-22 13:36 jasoncool1 阅读(121) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 22 下一页