349.(查找问题)求两个数组公共元素

349.(查找问题)求两个数组公共元素_第1张图片

349.(查找问题)求两个数组公共元素_第2张图片

使用set

class Solution {
    public int[] intersection(int[] nums1, int[] nums2) {
        // 将nums1中所有元素存到set中
        Set set=new HashSet();
        //用于存放结果的集合
         Set resultset=new HashSet(); 
        
        for(int i=0;i

你可能感兴趣的:(349.(查找问题)求两个数组公共元素)