摘要: class Solution { public boolean isStraight(int[] nums) { Arrays.sort(nums); int i = 3; if(nums[4]<3) return false; while(i>=0){ if(nums[i] == nums[i+1 阅读全文
posted @ 2020-08-21 20:41 欣姐姐 阅读(160) 评论(0) 推荐(0)
摘要: public int[] maxSlidingWindow(int[] nums, int k) { int len = nums.length; if(len == 0 ) return new int[0]; int[] res = new int[len-k+1]; int max = num 阅读全文
posted @ 2020-08-21 20:37 欣姐姐 阅读(203) 评论(0) 推荐(0)
摘要: public String reverseLeftWords(String s, int n) { int len = s.length(); n = n%len; String sub_str1 = s.substring(0,n); String sub_str2 = s.substring(n 阅读全文
posted @ 2020-08-21 17:44 欣姐姐 阅读(77) 评论(0) 推荐(0)
摘要: class Solution { public String reverseWords(String s) { s = s.trim(); String[] str = s.split(" "); StringBuilder sb = new StringBuilder(); int len = s 阅读全文
posted @ 2020-08-21 17:40 欣姐姐 阅读(86) 评论(0) 推荐(0)
摘要: List<List<Integer>> res = new ArrayList<>(); public int[][] findContinuousSequence(int target) { List<Integer> list = new ArrayList<>(); findOne(targe 阅读全文
posted @ 2020-08-21 17:31 欣姐姐 阅读(121) 评论(0) 推荐(0)
摘要: public int[] twoSum(int[] nums, int target) { int len = nums.length; if(len==1) if(target == nums[0]) return nums; else return new int[0]; int i = 0,j 阅读全文
posted @ 2020-08-21 16:27 欣姐姐 阅读(104) 评论(0) 推荐(0)
摘要: public int maxDepth(TreeNode root) { if(root == null) return 0; return 1+Math.max(maxDepth(root.left),maxDepth(root.right)); } 阅读全文
posted @ 2020-08-21 16:20 欣姐姐 阅读(81) 评论(0) 推荐(0)
摘要: 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)