Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
552 B
2
Indexable
Never
#include<bits/stdc++.h>
using namespace std;
int fun(vector<int>&a,vector<int>&b,int opn){
    int n= a.size(); 
 
    unordered_set<int>st(begin(a),end(a)); 
 
    int distA= st.size(); 
 
    for(auto x: b)
    {
        if(st.size()==a.size())break;
        st.insert(x);
    }
 
    int distAB= st.size();
 
    int replacable = distAB - distA ; 
 
    int ans=min(replacable,opn);
 
    return ans+distA; 
}
int main()
{
    vector<int>a{1,2,3,4,4};
    vector<int>b{5,6,7,8,9};
    cout<<fun(a,b,3);
    return 0;
}