class Solution {
public:
vector<int> intersect(vector<int>& nums1, vector<int>& nums2) {
int k=0;
int m=nums1.size();
int n=nums2.size();
vector<int> res[m];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(nums1[i]==nums2[j]){
res[k]=nums1[i];
k++;
break;
}
}
}
return res;
}
};
I had to find duplicates in two different arrays and return the same. But I'm getting the error
no viable overloaded '='
from the compiler in the line where I am storing my duplicates in the res[k]
vector.