Skip to content

PRO TIP Block youtube.com at the DNS level β€” Pi-hole, NextDNS or your hosts file β€” but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

DSA in Python – Number of Provinces Using Disjoint Set (Union-Find) | GFG Graph | Part 160 [Hindi]

994 views on YouTube

πŸ“˜ Welcome to Part 160 of Code & Debug’s DSA Python Course!

In this video, we solve the classic Number of Provinces problem using the powerful Disjoint Set (Union-Find) data structure.

This problem focuses on finding the number of connected components (provinces) in an undirected graph, where connections are given in the form of an adjacency matrix. The Union-Find approach efficiently helps us group connected cities and identify distinct provinces.

πŸ‘¨β€πŸ« What’s covered in this video:
βœ… Understanding the problem statement and real-world analogy
βœ… How Disjoint Set (Union-Find) helps in solving graph connectivity problems
βœ… Path Compression & Union by Rank optimization techniques
βœ… Complete Python implementation step-by-step
βœ… Time and Space Complexity breakdown
βœ… Quick comparison with DFS/BFS approaches

This is a very important problem for mastering Graph Connectivity, Union-Find, and efficient component counting in graphs.

πŸ”— GFG Problem – Number of Provinces:
https://www.geeksforgeeks.org/problems/number-of-provinces/1

πŸ“„ Full Playlist Sheet (All Questions in Order):
https://docs.google.com/spreadsheets/d/1AWE15Fy3wD2iqu2vjK_R7cCiuvSsjYQclcdZmHpF66o/edit?usp=sharing

πŸŽ“ Enroll in the FREE Python DSA Course:
https://codeanddebug.in/course/master-dsa-with-leetcode

πŸš€ Full DSA Track (Zero to Hero):
https://codeanddebug.in/course/zero-to-hero-python-dsa

Stay consistent and keep improving with Code & Debug.
Like | Share | Subscribe | Hit the πŸ””

#NumberOfProvinces #DisjointSet #UnionFind #GraphProblems #PythonDSA #GraphConnectivity #CodeAndDebug #Part160 #DSACourse