Question bank › Graphs Bfs
Dsa Graphs Bfs Medium

Social Network Friendships

In a social network, users can be friends with other users. You are given a list of friendships represented as pairs of integers (a, b), where a is friends with b. Write a function that finds the size of the largest connected group of users, where a connected group consists of users that are directly or indirectly friends. Input format: The first line contains an integer n (1 <= n <= 100), representing the number of friendships. The next n lines contain two integers a and b representing a friendship between user a and user b. Output format: An integer representing the size of the largest connected group of users. Example: Input: 5 0 1 1 2 2 3 4 5 3 4 Output: 5

Key concepts

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