You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/coANgIdBKAk
int beautifulPairs(vector<int> A, vector<int> B) { map<int, int> mp; int result = 0; for(int i = 0; i < A.size(); i++) mp[A[i]]++; for(int i = 0; i < B.size(); i++){ if(mp[B[i]]){ mp[B[i]]--; result++; } } return (result == A.size()) ? result - 1 : result + 1; }
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 →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/coANgIdBKAk