摘要: 学习瑞吉外卖 阅读全文
posted @ 2024-06-13 22:09 清川1 阅读(8) 评论(0) 推荐(0)
摘要: 难点在于不能重复 1.将数组进行排序 2.找到合适组合后将三个指针都要进行向后去重操作 1 class Solution { 2 public List<List<Integer>> threeSum(int[] nums) { 3 Arrays.sort(nums); 4 List<List<In 阅读全文
posted @ 2024-06-13 22:09 清川1 阅读(15) 评论(0) 推荐(0)
摘要: 没看懂 1 class Solution { 2 public List<Integer> findAnagrams(String s, String p) { 3 List<Integer>res=new ArrayList<>(); 4 int[]cnt=new int[26]; 5 int n 阅读全文
posted @ 2024-06-13 21:41 清川1 阅读(20) 评论(0) 推荐(0)
摘要: 相对于4重循环,改成两个二重循环O(n2) 使用HashMap存储前两个数组的和,再在另外两个数组的循环中找值 1 class Solution { 2 public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums 阅读全文
posted @ 2024-06-13 21:20 清川1 阅读(20) 评论(0) 推荐(0)
摘要: 我只能说 直接双循环 1 class Solution { 2 public int[] twoSum(int[] nums, int target) { 3 int[] ans=new int[2]; 4 for(int i=0;i<nums.length;i++){ 5 for(int j=i+ 阅读全文
posted @ 2024-06-13 20:42 清川1 阅读(18) 评论(0) 推荐(0)
摘要: 主要是查看HashMap中是否存储n,如果存储就说明非快乐数 各位的数平方相加的方法 1 class Solution { 2 public boolean isHappy(int n) { 3 HashMap<Integer,Integer> map=new HashMap<>(); 4 5 wh 阅读全文
posted @ 2024-06-13 20:27 清川1 阅读(18) 评论(0) 推荐(0)
摘要: 使用hashmap记录数字个数,如果nums1中重复数字多,遍历2时则不需要取少 如果2中重复数字多,则每次取到就-1,直至map内无值 1 class Solution { 2 public int[] intersect(int[] nums1, int[] nums2) { 3 HashMap 阅读全文
posted @ 2024-06-13 13:26 清川1 阅读(18) 评论(0) 推荐(0)
摘要: 1 class Solution { 2 public int[] intersection(int[] nums1, int[] nums2) { 3 int[] ans1=new int[1002]; 4 int[] ans2=new int[1002]; 5 for(int i:nums1){ 阅读全文
posted @ 2024-06-13 13:07 清川1 阅读(19) 评论(0) 推荐(0)