➤ Problem Link : FACEFRND
👉 Hint : Simple using hashed data structure like unordered_set in C++ STL
✅ C++ Solution :
#include<bits/stdc++.h> using namespace std; int main() { int i,j,n; cin>>n; int arr[n]; unordered_set<int>s; for(i=0;i<n;i++) { int x,y; cin>>arr[i]>>x; for(j=0;j<x;j++) { cin>>y; s.insert(y); } } int cnt=s.size(); for(i=0;i<n;i++) { if(s.find(arr[i])!=s.end()) cnt--; } cout<<cnt<<endl; return 0; }
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!