Amazon Online Assessment (OA) - Find Critical Servers

Given an undirected graph, find out all the vertices that, when removed, will make the graph disconnected.

Initially, the graph is connected.

For example, given the graph below:

Return [3, 6]. Because we can make the graph disconnected by removing either vertex 3 or vertex 6.

Input

The input consists of five arguments:

nodeNum: the total count of vertices in the graph. Each vertex has a unique ID in the range from 0 to nodeNum - 1 inclusive.

edges: a list of integer pairs representing all the edges in the graph.

Output

A list of integers representing the IDs of the articulation points.

Examples

Example 1:

Input:

nodeNum = 7

edges = [[0,1], [0,2], [1,3], [2,3], [2,5], [5,6], [3,4]]

Output: [2,3,5]

Try it yourself


Got a question?ย Ask the Teaching Assistantย anything you don't understand.

Still not clear? Ask in the Forum, ย Discordย orย Submitย the part you don't understand to our editors.

โ†
โ†‘TA ๐Ÿ‘จโ€๐Ÿซ