Question bank › Union Find
Dsa Union Find Easy

Community Divide

You are running a community divide challenge. You have a graph represented by a list of edges. Please find out how many separate components exist after processing all edges. The graph may contain self-loops and multiple edges. There must be at least `n` nodes before any edges are processed, and the input specifies both nodes along with their connections. Example Input: 4 1 2 1 3 3 4 Example Output: 1

Key concepts

union_finddivisionconnected_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.