Edges Whose Removal Disconnects a Network. The connected undirected graph has n labeled servers0 through n-1, with no self-loops or repeated connections.
### Problem
The connected undirected graph has n labeled servers 0 through n-1, with no self-loops or repeated connections. Return every edge whose removal makes some pair of servers unable to reach each other. Edges and their endpoint orientations may be returned in any order.
```cpp
class Solution {
public:
vector<vector<int>> criticalConnections(int n, vector<vector<int>>& connections);
};
```
### Examples
**Example 1:**
```text
Input: n = 3, connections = [[0,1],[1,2]]
Output: [[0,1],[1,2]]
Explanation: Removing either edge separates an endpoint from another server.
```
**Example 2:**
```text
Input: n = 4, connections = [[0,1],[1,2],[2,3],[3,0]]
Output: []
Explanation: Every removed edge has an alternate route around the remaining cycle.
```
### Constraints
- `2 <= n <= 100000`.
- The connected graph has between n-1 and 100000 edges.
- Each edge joins two distinct labels in `[0,n-1]`.
- There are no repeated undirected edges.
### Contract considerations
The output is a set of undirected critical edges; a fixed edge order is not required.
```hint Read the boundary condition
Must a reported undirected edge keep the same endpoint orientation and list position as in the input?
```
### What a Strong Answer Covers
The output is a set of undirected critical edges; a fixed edge order is not required.
### Follow-up Questions
Optional practice extension, separate from the original task: How would the algorithm change if parallel connections were allowed?
Overview: Edges Whose Removal Disconnects a Network. The connected undirected graph has n labeled servers0 through n-1, with no self-loops or repeated connections.
The connected undirected graph has n labeled servers 0 through n-1, with no self-loops or repeated connections. Return every edge whose removal makes some pair of servers unable to reach each other. Edges and their endpoint orientations may be returned in any order.
class Solution {
public:
vector<vector<int>> criticalConnections(int n, vector<vector<int>>& connections);
};
Examples
Example 1:
Input: n = 3, connections = [[0,1],[1,2]]
Output: [[0,1],[1,2]]
Explanation: Removing either edge separates an endpoint from another server.
Example 2:
Input: n = 4, connections = [[0,1],[1,2],[2,3],[3,0]]
Output: []
Explanation: Every removed edge has an alternate route around the remaining cycle.
Constraints
2 <= n <= 100000
.
The connected graph has between n-1 and 100000 edges.
Each edge joins two distinct labels in
[0,n-1]
.
There are no repeated undirected edges.
Contract considerations
The output is a set of undirected critical edges; a fixed edge order is not required.
What a Strong Answer Covers Guidance
The output is a set of undirected critical edges; a fixed edge order is not required.
Follow-up Questions Guidance
Optional practice extension, separate from the original task: How would the algorithm change if parallel connections were allowed?