We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
/* * Complete the 'beautifulPairs' function below. * * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER_ARRAY A * 2. INTEGER_ARRAY B */void_print(constmultiset<int>&s){for(autoe:s){cout<<e<<" ";}cout<<endl;}intbeautifulPairs(vector<int>A,vector<int>B){multiset<int>ms(B.begin(),B.end());intcount=0;for(autoa:A){autoit=ms.find(a);if(it!=ms.end()){count++;ms.erase(it);}}// cout << count << endl;// _print(ms);if(ms.empty()){returncount-1;}returncount+1;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Pairs
You are viewing a single comment's thread. Return to all comments →