摘要:
public int longestConsecutive(int[] nums) { int result = 0; Set<Integer> set = new HashSet<>(); for(int i = 0 ; i < nums.length ; i++) { set.add(nums[ 阅读全文
摘要:
示例代码: public static void main(String[] args) { int b = 0; change(b); System.out.println(b); } public static void change(int a) { a = 1; } 结果: 为什么b的值不会 阅读全文
摘要:
思路一:从中心开始扩展,分两种情况判断 public int maxLength = 1; public int start = 0; public String longestPalindrome(String s) { if(null == s || s.length() == 0) { ret 阅读全文
摘要:
public TreeNode buildTree(int[] preorder, int[] inorder) { return helper(preorder,inorder,0,preorder.length-1,0,inorder.length-1); } public TreeNode h 阅读全文
摘要:
class Solution { public int[] maxSlidingWindow(int[] nums, int k) { //双指针滑窗 int l = nums.length; if( l == 0)return nums; int[] res = new int[l - k + 1 阅读全文
摘要:
class Solution { public List<Integer> topKFrequent(int[] nums, int k) { //先统计每个数字出现的频率 Map<Integer,Integer> map = new HashMap<>(); for(int i = 0; i < 阅读全文
摘要:
拓扑排序 class Solution { public int[] findOrder(int numCourses, int[][] prerequisites) { //统计所有节点的入度 int[] res = new int[numCourses]; int[] in = new int[ 阅读全文