Question bank › Graphs Bfs
Dsa Graphs Bfs Easy

Social Network Degrees

You are given a list of friendships represented as pairs of integers, where each integer represents a user in a social network. Your task is to determine the degree of separation between two given users (the number of edges in the shortest path from one user to the other). If no connection exists, return -1. For example, given the input: 5 0 1 0 2 1 2 1 3 2 4 0 4 The output should be: 2

Key concepts

graphsbfsnetwork

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.