Doubt on the holiday_accommodation problem

for (auto nbr_pair : l[node])
{
int nbr = nbr_pair.first;
int wt = nbr_pair.second;

dfs_helper(0, visited, count, ans); <== this line according to video node is zero .If I initialize node as as a zero then how the list is executing in the for loop

Actually I mean to say that l[0].first = of its neighbour then l[0] is once will be rounding in the loop.Then how the total loop is executing and how count[node] is returning to this line

count[node] += dfs_helper(nbr, visited, count, ans);

hello @kaushikghosh199832

we are starting our dfs from node zero.
from 0 we are calling dfs to all its child/neighbouring node (which will subsequently call dfs to their child/neighbour ) and then adding the value returned by them in our current node.

I think u should refer this dfs visualisation to understand the flow of the program -> https://www.cs.usfca.edu/~galles/visualization/DFS.html

this might help u in understanding the flow of the program.

if still u get any issue then pls rewatch dfs video .

refer this for dfs -> https://www.geeksforgeeks.org/depth-first-search-or-dfs-for-a-graph/

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.