sir if we cannot traverse till a specific node then how do we add to the list?
like in the test case, the nodes are there but not connected to source anyhow
Bfs doubt in adding to list
in that case while printing the answer
simply print -1 (since it cannot be reached from source node)
refer this code
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.