随笔分类 - 力扣刷题随笔
日常刷题记录
技术力底下
大佬轻喷
摘要:1 class Solution { 2 public int wiggleMaxLength(int[] nums) { 3 int up = 1, down = 1; 4 if(nums.length == 0) return 0; 5 for(int i = 0; i < nums.lengt
阅读全文
摘要:1 class Solution { 2 public boolean lemonadeChange(int[] bills) { 3 int count5 = 0, count10 = 0; 4 if(bills[0] != 5) return false; 5 for(int i = 0; i
阅读全文
摘要:1 class Solution { 2 public String longestPalindrome(String s) { 3 if(s.equals("")) return ""; 4 String origin = s; 5 String reverse = new StringBuffe
阅读全文
摘要:1 class Solution { 2 public int matrixScore(int[][] A) { 3 int len1 = A.length, len2 = A[0].length; 4 5 for(int i = 0; i < len1; i++){ 6 if(A[i][0] ==
阅读全文
摘要:方法一 函数库合并 毫无技术含量 不讲了 1 class Solution { 2 public double findMedianSortedArrays(int[] nums1, int[] nums2) { 3 int[] c= new int[nums1.length+nums2.lengt
阅读全文
摘要:好耶 今天的日常又能做咯 来个评论区老哥的骚套路 1 class Solution { 2 public List<List<Integer>> generate(int numRows) { 3 Integer[][] a= {{1}, 4 {1, 1}, 5 {1, 2, 1}, 6 {1, 3
阅读全文
摘要:最近两天的日常题也太难了罢 今天的抄个答案放弃了 索性从头开始复习一下1 ~ 300题好了 本人末流211本科 不想考研 大一大二学习不是很用功 现在在努力追进度 脑子不好使 大家轻喷 class Solution { public int[] twoSum(int[] nums, int targ
阅读全文
摘要:太难了 不会写 试试写过程分析吧 方法一 哈希表+最小堆 1 class Solution { 2 public boolean isPossible(int[] nums) { 3 Map<Integer, PriorityQueue<Integer>> map = new HashMap<Int
阅读全文
摘要:1 public int findDuplicate(int[] nums) { 2 Arrays.sort(nums); 3 for (int i = 0; i < nums.length - 1; i++) { 4 if (nums[i] == nums[i + 1]) { 5 return n
阅读全文
摘要:1 class Solution { 2 public int countPrimes(int n) { 3 int count = 0; 4 for(int i = 2; i < n; i++){ 5 if(isPrime(i)) count++; 6 } 7 return count; 8 }
阅读全文
摘要:1 int binarySearch(int[] nums, int target) { 2 int left = 0, right = ...; 3 4 while(...) { 5 int mid = (right + left) / 2; 6 if (nums[mid] == target)
阅读全文
摘要:1 class Solution { 2 public int[] searchRange(int[] nums, int target) { 3 int[] res = {-1 , -1}; 4 int len = nums.length; 5 for(int i = 0; i < len; i+
阅读全文

浙公网安备 33010602011771号