摘要:
class Solution { public List<List<Integer>> verticalOrder(TreeNode root) { if(root == null) return new ArrayList<>(); Map<Integer,List<Integer>> map = 阅读全文
摘要:
class Solution { public int longestConsecutive(TreeNode root) { dfs(root); return res; } private int res = 0; public int[] dfs(TreeNode root) { // 以ro 阅读全文
摘要:
class Solution { public int maxPathSum(TreeNode root) { dfs(root); return res; } int res = Integer.MIN_VALUE; public int dfs(TreeNode root) { // 返回以当前 阅读全文
摘要:
方法一: class Solution { public int longestConsecutive(int[] nums) { Set<Integer> set = new HashSet<>(); for(int num : nums) set.add(num); int res = 0; f 阅读全文
摘要:
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 阅读全文
摘要:
方法一: class Solution { public String removeKdigits(String num, int k) { int n = num.length(); if(n <= k) return "0"; StringBuilder sb = new StringBuild 阅读全文