摘要: class Solution { public List<List<Integer>> verticalOrder(TreeNode root) { if(root == null) return new ArrayList<>(); Map<Integer,List<Integer>> map = 阅读全文
posted @ 2020-07-14 19:23 Sexyomaru 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(350) 评论(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 阅读(122) 评论(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 阅读(92) 评论(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 阅读(104) 评论(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 阅读(122) 评论(0) 推荐(0) 编辑