#include
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int k,n;
cin>>k>>n;
set s;
while(k–)
{
long long int ar[n];
for(long long int i=0;i<n;i++)
{
cin>>ar[i];
s.insert(ar[i]);
}
}
for(auto it=s.begin();it!=s.end();it++)
{
cout<<*it<<" ";
}
return 0;
}
What is the problem in this code ,i used set to merge the k sorted array in sorted ordered
@firozbhaikardar21
hello firoz,
set contains unique element only. that why u are getting wrong output
for example if two array are 1 1 1 2 and 1 1 1
then u will get 1 2 as output but 1 1 1 1 1 1 2 is corrrect output
thankyou sirrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.