An infrastructure dashboard highlights single points of failure. Servers are numbered 0 to n - 1, and cables[i] = [a, b] is a two-way cable. Two servers may be joined by more than one cable.
A critical cable is one whose removal leaves some pair of servers that were connected unable to reach each other. Write criticalCables(n, cables) that returns every critical cable as [smaller, larger], with the list sorted by the first number and then the second.
Input: n = 5, cables = [[0,1],[1,2],[2,0],[1,3],[3,4]] Output: [[1,3],[3,4]]
The triangle 0-1-2 survives losing any one cable, but cutting 1-3 or 3-4 separates servers.
Input: n = 3, cables = [[0,1],[1,2],[2,0]] Output: []
Every cable is part of a loop, so there's always another way around.
1 <= n <= 5 * 10^40 <= cables.length <= 10^50 <= a, b < n, a !== bRun tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #477 Cables Whose Failure Splits the Network. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.