feat: 2025-10-28打卡

This commit is contained in:
wu xiangkai
2025-10-28 15:52:13 +08:00
parent fc82d7eb10
commit 2fa03ec244
13 changed files with 486 additions and 6 deletions

View File

@@ -0,0 +1,32 @@
/*
* @lc app=leetcode id=350 lang=java
*
* [350] Intersection of Two Arrays II
*/
// @lc code=start
import java.util.List;
class Solution {
public int[] intersect(int[] nums1, int[] nums2) {
Arrays.sort(nums1);
Arrays.sort(nums2);
int i = 0, j = 0;
List<Integer> ret = new ArrayList<>();
while(i<nums1.length && j < nums2.length) {
if(nums1[i] == nums2[j]) {
ret.add(nums1[i]);
i++;
j++;
} else if(nums1[i] < nums2[j]) {
i++;
} else {
j++;
}
}
return ret.stream().mapToInt(f->f).toArray();
}
}
// @lc code=end