Find All People With Secret Problem

link to the problem

class Solution {
public:
vector findAllPeople(int n, vector<vector>& meetings, int firstPerson) {
vectorv;
int y=meetings.size();
map<int,vector>mp;
mp[0].push_back(0);
mp[0].push_back(firstPerson);
for(int i=0;i<y;i++)
{
mp[meetings[i][2]].push_back(meetings[i][0]);
mp[meetings[i][2]].push_back(meetings[i][1]);
}

    for(auto it : mp)
    {
        if((it.second[0]==firstPerson && it.second[1]==0) || (it.second[1]==firstPerson && it.second[0]==0))
        {
            v.push_back(0);
            v.push_back(firstPerson);
        }
       else
       {
           if(find(v.begin(),v.end(),it.second[0])!=v.end() && find(v.begin(),v.end(),it.second[1])==v.end())
           {
             
               v.push_back(it.second[1]);
           }
           else if(find(v.begin(),v.end(),it.second[1])!=v.end() && find(v.begin(),v.end(),it.second[0])==v.end())
           {        
               v.push_back(it.second[0]);
           }
       }
    }
    sort(v.begin(),v.end());

    return v;


}

};

Sir,I have tried to use time variable as key,but it fails on some cases,where more than one event occur simultaneously.Please help me out with this question.
Sir how can queue help to solve this problem(as in graphs bfs).

hi @sharmasrishti891
refer this https://leetcode.com/problems/find-all-people-with-secret/discuss/1599972/C%2B%2B-or-BFS-Solution

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.