what is the error?
Intersection of 2 arrays using hashmap
Hey @Vibhuti0206
You’re taking input in the wrong order,
acc to the question, you’ve to first input n, then input the two arrays containing n elements each,
you wrote:
for(int i=0;i<n;i++)
{
cin>>arr1[i];
cin>>arr2[i];
}
you need to write:
for(int i=0;i<n;i++)
{
cin>>arr1[i];
}
for(int i=0;i<n;i++)
{
cin>>arr2[i];
}
still it is giving: prog.cpp:38:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i=0; i < (l.size()); i++) { ^~~~~~~~~~ prog.cpp:39:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (i != (l.size()-1)) ^~~~~~~~~~~~~ prog.cpp:40:24: error: no match for ‘operator[]’ (operand types are ‘std::__cxx11::list’ and ‘int’) cout<<l[i]<<", "; ^ prog.cpp:42:24: error: no match for ‘operator[]’ (operand types are ‘std::__cxx11::list’ and ‘int’) cout<<l[i]; ^ error