摘要: 力扣题目链接 class Solution { public List<List<Integer>> threeSum(int[] nums) { List<List<Integer>> res = new ArrayList<>(); int n = nums.length; //剪枝,当数组小于 阅读全文
posted @ 2022-02-03 22:19 蹇爱黄 阅读(43) 评论(0) 推荐(0)
摘要: 力扣题目链接 跟两数之和好像啊 于是写了一个HashMap class Solution { public int[] twoSum(int[] numbers, int target) { int[] a = new int[2]; Map<Integer,Integer> map = new H 阅读全文
posted @ 2022-02-03 21:11 蹇爱黄 阅读(37) 评论(0) 推荐(0)
摘要: 力扣题目链接 感觉自己是真的菜。。。每次都看大佬题解 public class Solution { public int maxProduct(String[] words) { //字符数组的长度 int len = words.length; //定义一个长度为字符数组长度的新数组 int[] 阅读全文
posted @ 2022-02-03 20:47 蹇爱黄 阅读(47) 评论(0) 推荐(0)
摘要: 力扣题目链接 不知道别的方法怎么样,只能想出HashMap class Solution { public int singleNumber(int[] nums) { Map<Integer,Integer> map = new HashMap<Integer,Integer>(); for(in 阅读全文
posted @ 2022-02-03 18:11 蹇爱黄 阅读(41) 评论(0) 推荐(0)
摘要: 力扣题目链接 位运算 class Solution { public int[] countBits(int n) { int[] nums = new int[n+1]; for(int i=0;i<=n;++i){ for(int j=0;j<32;++j){ nums[i] += (i>>j) 阅读全文
posted @ 2022-02-03 16:52 蹇爱黄 阅读(29) 评论(0) 推荐(0)