I don't understand why in line 8 you take node from 0 to n-1. The nodes can start from any value right? Not just 0. Why not just input edges[i][0] and edges[i][1] instead?
Don’t think it matters. Either way it’s going to be a O(N) runtime. It’s whatever you prefer to code and more comfortable with that you should write. I prefer standard DFS and am more comfortable with it so I went with this solution.
Very clear explanation, thank you so much! I only knew how to use union find to solve this problem instead of dfs, now i know both!
Glad I found your channel. You explain things clearly and articulate well.
Thank you! Welcome to the channel
Excellent, Implementation is original and clean. thanks
Nice Explanation. Thanks a lot
No problem, glad you found it useful! Make sure to subscribe so you don't miss future videos!
keep uploading king, thanks!!!! subbed. i hope i make it, thank you for your uploads
Thank you for the support and your kind words! Any videos you’d like to see in particular?
this channel is so goood
I don't understand why in line 8 you take node from 0 to n-1. The nodes can start from any value right? Not just 0. Why not just input edges[i][0] and edges[i][1] instead?
thank you bro
Thanks for the video! Is the union find algorithm better than dfs for this question?
Don’t think it matters. Either way it’s going to be a O(N) runtime. It’s whatever you prefer to code and more comfortable with that you should write.
I prefer standard DFS and am more comfortable with it so I went with this solution.