MCPcopy Create free account
hub / github.com/LeadCoding/3-weeks-Google-Prep / dfs

Function dfs

01. Graphs/03. DFS/1. JourneyToTheMoon.cpp:8–16  ·  view source on GitHub ↗

https://www.hackerrank.com/challenges/journey-to-the-moon/problem the people in 1 component cant go together but thet can go with rest of the people */

Source from the content-addressed store, hash-verified

6 the people in 1 component cant go together but thet can go with rest of the people
7*/
8void dfs(int i,map<int,vector<int>>&m,vector<int>&visited,long long &temp) {
9 visited[i]=1;
10 temp++;
11 for(auto a:m[i]) {
12 if(visited[a]==0) {
13 dfs(a,m,visited,temp);
14 }
15 }
16}
17int journeyToMoon(int n, vector<vector<int>> astronaut) {
18 map<int,vector<int>> m;
19 for(auto a:astronaut) {

Callers 1

journeyToMoonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected