1105. Articulation Points Using Tarjan's Algorithm

HardGraphsSCCDFSGraph

Given an undirected graph with n nodes and edges, return all articulation points (cut vertices) — nodes whose removal increases the number of connected components — sorted in ascending order, using Tarjan's algorithm. The input is JSON {n, edges}.

Input: JSON {n, edges}.

Output: Array — the sorted articulation points.

Examples

Example 1
Input: {"n":5,"edges":[[0,1],[1,2],[2,0],[1,3],[3,4]]}
Output: [1,3]
Explanation: Removing 1 or 3 disconnects the graph.
Example 2
Input: {"n":3,"edges":[[0,1],[1,2],[2,0]]}
Output: []
Explanation: A cycle has no cut vertex.
Example 3
Input: {"n":3,"edges":[[0,1],[1,2]]}
Output: [1]
Explanation: The middle is a cut vertex.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →