3
vector<int> findAllPeople(int n, vector<vector<int>> &meetings, int firstPerson) {4
// create the graph betwen the persons5
vector<vector<pair<int, int>>> graph(n);6
for (int i = 0; i < meetings.size(); ++i) {7
graph[meetings[i][0]].push_back({meetings[i][1], meetings[i][2]});8
graph[meetings[i][1]].push_back({meetings[i][0], meetings[i][2]});11
// using min heap , using time as the sort order key.12
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;14
// Add both 0 and firstPerson in the queue as they know the secret initially16
q.push({0, firstPerson});18
// vector to store res21
// marking the persons as visited if they have met and shared the secret to22
// all possible persons they could23
vector<bool> visited(n, false);26
pair<int, int> curr = q.top();29
int person = curr.second;30
int time = curr.first;32
// person had already shared the secret with others33
if (visited[person]) {36
visited[person] = true;38
// iterate all the meetings of this person and add the potential new39
// persons he can share secret with40
for (pair<int, int> neigh : graph[person]) {41
if (!visited[neigh.first] && time <= neigh.second) {42
q.push({neigh.second, neigh.first});47
// all visited persons know the secret48
for (int i = 0; i < n; ++i) {