[Java] Leetcode 547. Number of Provinces [Union Find #1]

preview_player
Показать описание
In this video, I'm going to show you how to solve Leetcode 547. Number of Provinces which is related to Union Find.

Here’s a quick rundown of what you’re about to learn:
⭐️ Course Contents ⭐️
⌨️ (0:00) Question
⌨️ (2:50) Solution Explain

In the end, you’ll have a really good understanding on how to solve Leetcode 547. Number of Provinces and questions that are similar to this Union Find.

Now, if you want to get good at Union Find, please checkout my Union Find playlist.

Рекомендации по теме
Комментарии
Автор

Really enjoyed watching the video.
Clean and clear explanation.

vadirajjahagirdar
Автор

What is the advantage of using union find for this problem over dfs/bfs?

morgan
Автор

When the I and J don't have a connection i.e =0 then when we have set their parent as par[i]=i already, won't the components counted with no connection to any province, here would create problem, is this give that every ele is part of some province

mickyman
Автор

Appreciate your extra effort in recording and publishing videos apart from the practice. Your videos really saves a lot of time. Will the soln above work when components > n ? Other example [1, 1, 0], [0, 0, 1], [0, 1, 1]?

estrelladesigner
join shbcf.ru