Skip to content

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

Open
@zhihali

Description

@zhihali

在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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions