How iterator is working in this code

for(int nbr:l[node]){
if(!visited[nbr]){
q.push(nbr);
//mark that nbr as visietd
visited[nbr]=true;
}
}

code- https://ide.codingblocks.com/s/325401

hi @divesh2000 this is an alternate way to write a for loop
nbr will give you each element of l[node] one by one

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.