Question bank › Graphs Dfs
Dsa Graphs Dfs Medium

Company Connectivity

You are given a list of employee connections in a company, represented as an undirected graph where each node is an employee and each edge is a direct connection. Determine the number of distinct groups of employees who can reach each other through any number of connections. Input Format: - The first line contains an integer, n (the number of connections). - The next n lines each contain two integers, u and v, indicating a connection between employee u and employee v. Output Format: - Print a single integer, the number of distinct groups of connected employees. Example: Input: 5 0 1 0 2 1 2 3 4 5 6 Output: 3

Key concepts

graphsdfsconnected components

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.