2022年3月29日
摘要:
package leetcode; public class offer_14_1 { public int cuttingRope(int n) { int max=1; int[] dp=new int[n+1]; //当n≤3时,不符合动态规划 if(n<=3) { return Math.m
阅读全文
posted @ 2022-03-29 20:04
一仟零一夜丶
阅读(17)
推荐(0)
摘要:
package leetcode; import java.util.ArrayList; import java.util.List; public class offer_57_2 { public int[][] findContinuousSequence(int target) { int
阅读全文
posted @ 2022-03-29 20:03
一仟零一夜丶
阅读(16)
推荐(0)
2022年3月26日
摘要:
package leetcode; import java.util.Comparator; import java.util.PriorityQueue; public class demo_215 { //建立一个大顶堆 public int findKthLargest(int[] nums,
阅读全文
posted @ 2022-03-26 16:16
一仟零一夜丶
阅读(30)
推荐(0)
2022年3月24日
摘要:
package leetcode; public class offer_66 { public int[] constructArr(int[] a) { if(a==null||a.length==0) {return a;} //两个动态规划数组,存储当前位置连续连续积 int[] dp1=n
阅读全文
posted @ 2022-03-24 10:48
一仟零一夜丶
阅读(22)
推荐(0)
摘要:
package leetcode; public class offer_39 { public int majorityElement(int[] nums) { int target=nums[0]; int count=0; //相同count就减一,不同则加一,因为target总存在,所以最
阅读全文
posted @ 2022-03-24 09:56
一仟零一夜丶
阅读(21)
推荐(0)
2022年3月23日
摘要:
package leetcode; public class offer_56_2 { public int singleNumber(int[] nums) { //用一个数组记录每一位出现的次数,如果出现三次那一定是三的倍数,取余后就是当前值 int[] arr=new int[32]; for
阅读全文
posted @ 2022-03-23 21:13
一仟零一夜丶
阅读(19)
推荐(0)
摘要:
package leetcode; public class offer_56_1 { public int[] singleNumbers(int[] nums) { int temp=0; //找出两个不同数的异或值 for(int num:nums) { temp=temp^num; } //
阅读全文
posted @ 2022-03-23 11:34
一仟零一夜丶
阅读(17)
推荐(0)
2022年3月22日
摘要:
package leetcode; public class offer_15 { //n与n-1进行与运算会消除n中最后一个1 public int hammingWeight(int n) { int count=0; while(n!=0) { count=count+1; n=n&(n-1)
阅读全文
posted @ 2022-03-22 11:11
一仟零一夜丶
阅读(20)
推荐(0)
摘要:
package leetcode; public class offer_65 { //^ 亦或 相当于 无进位的求和 //& 与 相当于求每位的进位数 //a=b => (a^b)^((a&b))<<1 public int add(int a, int b) { while(b!=0) { in
阅读全文
posted @ 2022-03-22 10:39
一仟零一夜丶
阅读(14)
推荐(0)
2022年3月21日
摘要:
package leetcode; public class offer_33 { public boolean verifyPostorder(int[] postorder) { return isPost(postorder, 0, postorder.length-1); } public
阅读全文
posted @ 2022-03-21 17:31
一仟零一夜丶
阅读(26)
推荐(0)