I tried this approach but don't get the right answer

I did a dfs from each node and the node with the shortest number of elements should be the answer but it doesn’t work.
code-https://ide.codingblocks.com/s/343663

@amanb25 i don’t think you can initialize array vis like this. why don’t you try taking it same as you take graph of constant size.

1 Like

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.