. [Swift] LeetCode1192 find the "key connection" in the cluster | Critical Connections in a Network

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤ micro-channel public number: to dare (WeiGanTechnologies)
➤ blog Park address: San-ching Wing Chi ( https://www.cnblogs.com/strengthen/ )
➤GitHub address: https://github.com/strengthen/LeetCode
➤ original address: HTTPS: //www.cnblogs. com / strengthen / p / 11521660.html
➤ If the address is not a link blog Park Yong Shan Chi, it may be crawling author of the article.
➤ text has been modified update! Click strongly recommended that the original address read! Support authors! Support the original!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

There are n servers numbered from 0 to n-1 connected by undirected server-to-server connections forming a network where connections[i] = [a, b] represents a connection between servers a and b. Any server can reach any other server directly or indirectly through the network.

critical connection is a connection that, if removed, will make some server unable to reach some other server.

Return all critical connections in the network in any order.

 

Example 1:

Input: n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]
Output: [[1,3]]
Explanation: [[3,1]] is also accepted.

 

Constraints:

  • 1 <= n <= 10^5
  • n-1 <= connections.length <= 10^5
  • connections[i][0] != connections[i][1]
  • There are no repeated connections.

Stay button data center  n servers, respectively from  0 the  n-1 way the numbers.

Between them with "server to server" in the form of point to point interconnect to form a cluster, the connection which  connections is undirected.

Formally, connections[i] = [a, b] it represents the server  a , and  b a connection between. Any server can reach any other network servers either directly or indirectly.

"The key connection" is the important connections in the cluster, that is, if we remove it, it will lead to some servers can not access other servers.

In any order you please return all "key connection" within the cluster.

 

Example 1:

Input: n = 4, connections = [ [0,1], [1,2], [2,0], [1,3]] 
Output: [[1,3]] 
Explanation: [[3,1] ] is correct.

 

prompt:

  • 1 <= n <= 10^5
  • n-1 <= connections.length <= 10^5
  • connections[i][0] != connections[i][1]
  • No duplicate connections

Guess you like

Origin www.cnblogs.com/strengthen/p/11521660.html