youngyangyang04 / leetcode-master

《代码随想录》LeetCode 刷题攻略:200道经典题目刷题顺序,共60w字的详细图解,视频难点剖析,50余张思维导图,支持C++,Java,Python,Go,JavaScript等多语言版本,从此算法学习不再迷茫!🔥🔥 来看看,你会发现相见恨晚!🚀
51.18k stars 11.41k forks source link

Union Find知识点可以增加更多例题 #2771

Open zhihali opened 1 week ago

zhihali commented 1 week ago

在Amazon和Meta的面试中Union Find并查集时候考到的,除了卡马网的三道题建议增加一些leetcode上的板子题作为训练。

以下是我做了很多之后整理出来比较好的题

261 - Graph Valid Tree

This problem asks you to determine if a given undirected graph is a valid tree.
A valid tree is an undirected graph in which any two vertices are connected by exactly one path.
It's typically solved using Union-Find (Disjoint Set) or Depth-First Search (DFS) algorithms.

323 - Number of Connected Components in an Undirected Graph

This problem asks you to count the number of connected components in an undirected graph.
It can be solved using either Depth-First Search (DFS), Breadth-First Search (BFS), or Union-Find algorithms.

721 - Accounts Merge

This problem involves merging email accounts based on common email addresses.
It's typically solved using a Union-Find (Disjoint Set) data structure or Depth-First Search (DFS).

547 - Number of Provinces

This problem asks you to find the number of provinces (connected components) in a graph represented by an adjacency matrix.
It can be solved using Depth-First Search (DFS), Breadth-First Search (BFS), or Union-Find algorithms.

305 - Number of Islands II

This is a dynamic version of the Number of Islands problem.
It involves adding land to a 2D grid and counting the number of islands after each addition.
It's typically solved using a Union-Find (Disjoint Set) data structure.
Dream4ctor commented 13 hours ago

tks,bro :)