Critical Connection Problem Statement

In a network with 'N' system nodes, identified from 0 to N-1, and 'M' connections, determine all critical connections. A connection is critical if its removal disrupts the network connectivity between the nodes involved.

Input:

The first line contains a positive integer 'T', representing the number of test cases. Each test case starts with two integers 'N' and 'M', indicating the count of system nodes and connections respectively. This is followed by 'M' lines, each containing two space-separated integers 'u' and 'v', describing a connection between nodes 'u' and 'v'.

Output:

For each test case, begin with an integer 'X' representing the count of critical connections. The subsequent 'X' lines list pairs of integers 'u' and 'v', indicating a critical connection where 'u' < 'v'. Each test case's output is separated by a line.

Example:

For given N = 4, M = 4, a critical connection exists between system node 0 and 1.

Constraints:

  • 1 <= T <= 5
  • 1 <= N, M <= 106
  • 0 <= u, v <= N - 1
  • There are no repeated connections.
  • Time Limit: 1 sec.

Note:

No need to print anything; focus on implementing the function.

Be the first one to answer
Add answer anonymously...
Amazon Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter