Question bank › Union Find
Dsa Union Find Easy

Minimize Redundant Connections

You are tasked with building a network with a specified number of nodes. However, some connections provided are redundant. Your goal is to determine the minimum number of connections that can be removed to keep the network fully connected. Input Format: - The first line contains two integers N (1 ≤ N ≤ 1000), the number of nodes, and M (1 ≤ M ≤ 1000), the number of connections. - Each of the next M lines contains two integers a and b (1 ≤ a, b ≤ N), indicating a connection between nodes a and b. Output Format: - Print the minimum number of connections that need to be removed to maintain connectivity. Example Input: 5 5 1 2 2 3 3 1 1 4 4 5 Example Output: 1

Key concepts

union_findgraph

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.