上一页 1 ··· 7 8 9 10 11 12 13 14 15 下一页
摘要: class Solution { public int longestConsecutive(TreeNode root) { dfs(root); return res; } private int res = 0; public int[] dfs(TreeNode root) { // 以ro 阅读全文
posted @ 2020-07-14 17:38 Sexyomaru 阅读(358) 评论(0) 推荐(0)
摘要: class Solution { public int maxPathSum(TreeNode root) { dfs(root); return res; } int res = Integer.MIN_VALUE; public int dfs(TreeNode root) { // 返回以当前 阅读全文
posted @ 2020-07-14 17:35 Sexyomaru 阅读(126) 评论(0) 推荐(0)
摘要: 方法一: class Solution { public int longestConsecutive(int[] nums) { Set<Integer> set = new HashSet<>(); for(int num : nums) set.add(num); int res = 0; f 阅读全文
posted @ 2020-07-14 11:05 Sexyomaru 阅读(98) 评论(0) 推荐(0)
摘要: class Solution { public Node connect(Node root) { if(root==null) return root; if(root.left!=null && root.right!=null){ root.left.next=root.right; } if 阅读全文
posted @ 2020-07-14 10:43 Sexyomaru 阅读(107) 评论(0) 推荐(0)
摘要: 方法一: class Solution { public String removeKdigits(String num, int k) { int n = num.length(); if(n <= k) return "0"; StringBuilder sb = new StringBuild 阅读全文
posted @ 2020-07-14 09:58 Sexyomaru 阅读(124) 评论(0) 推荐(0)
摘要: class Solution { public TreeNode deleteNode(TreeNode root, int key) { if(root == null) return null; if(root.val == key) { if(root.left == null) { retu 阅读全文
posted @ 2020-07-13 09:46 Sexyomaru 阅读(116) 评论(0) 推荐(0)
摘要: 方法一:层序遍历,只要节点不连续,返回false class Solution { public boolean isCompleteTree(TreeNode root) { Queue<TreeNode> queue=new LinkedList<>(); TreeNode prev=root; 阅读全文
posted @ 2020-07-13 09:39 Sexyomaru 阅读(179) 评论(0) 推荐(0)
摘要: class Solution { public double maxProbability(int n, int[][] edges, double[] succProb, int start, int end) { Map<Integer,List<Node>> map = new HashMap 阅读全文
posted @ 2020-07-12 15:29 Sexyomaru 阅读(218) 评论(0) 推荐(0)
摘要: class Solution { public boolean winnerSquareGame(int n) { boolean[] dp = new boolean[n+1]; // dp[i] 表示有i个石子,alice先手是否可以赢 for(int i = 1; i * i <= n; i+ 阅读全文
posted @ 2020-07-12 14:30 Sexyomaru 阅读(123) 评论(0) 推荐(0)
摘要: 分析:逆向dp class Solution { public int calculateMinimumHP(int[][] dungeon) { if(dungeon.length == 0 || dungeon[0].length == 0) return 0; int m = dungeon. 阅读全文
posted @ 2020-07-12 13:33 Sexyomaru 阅读(171) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 下一页