摘要:
class Solution { int res; int k; public int kthLargest(TreeNode root, int k) { this.k = k; dfs(root); return res; } private void dfs(TreeNode root) { 阅读全文
posted @ 2020-08-21 14:54
欣姐姐
阅读(79)
评论(0)
推荐(0)
摘要:
public int countDigitOne(int n) { int digit = 1, res = 0; int high = n / 10, cur = n % 10, low = 0; while(high != 0 || cur != 0) { if(cur == 0) res += 阅读全文
posted @ 2020-08-21 14:52
欣姐姐
阅读(88)
评论(0)
推荐(0)
摘要:
public int missingNumber(int[] nums) { int n = nums.length; int i = 0; while(i<n){ if(nums[i]!=i) return i; else{ i++; } } return n; } 阅读全文
posted @ 2020-08-21 12:02
欣姐姐
阅读(125)
评论(0)
推荐(0)
摘要:
public int search(int[] nums, int target) { int len = nums.length; int i = 0,j = -1; while(i<len){ if(nums[i] == target){ j = i+1; while(j<len){ if(nu 阅读全文
posted @ 2020-08-21 11:57
欣姐姐
阅读(94)
评论(0)
推荐(0)
摘要:
class Solution { public char firstUniqChar(String s) { int len = s.length(); Set<Character> set = new HashSet<>(); for(int i = 0;i<len;i++){ char ch = 阅读全文
posted @ 2020-08-21 11:09
欣姐姐
阅读(211)
评论(0)
推荐(0)
摘要:
class Solution { public int maxSubArray(int[] nums) { //动态规划 int len = nums.length; int[] res = new int[len]; int max = nums[0]; res[0] = nums[0]; if( 阅读全文
posted @ 2020-08-21 09:41
欣姐姐
阅读(79)
评论(0)
推荐(0)
摘要:
public MedianFinder() { } PriorityQueue<Integer> max = new PriorityQueue<>(); PriorityQueue<Integer> min = new PriorityQueue<Integer>(11,new Comparato 阅读全文
posted @ 2020-08-21 09:11
欣姐姐
阅读(95)
评论(0)
推荐(0)
摘要:
public int[] getLeastNumbers(int[] arr, int k) { //最小的k个数 Arrays.sort(arr); return Arrays.copyOfRange(arr,0,k); } public int[] getLeastNumbers(int[] a 阅读全文
posted @ 2020-08-21 09:10
欣姐姐
阅读(83)
评论(0)
推荐(0)

浙公网安备 33010602011771号