The Social Graph
A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L3
Problem
Given a list of groups (each group is a list of person names), compute per-person friend count: for a group [A, B], both A and B gain each other as friends. For a singleton [X], X exists but gains no friend from that row. Friendships are deduplicated: if A and B appear together in multiple groups, it is still one friendship. Return a dict mapping each person to their distinct friend count.
Summary
Everyone knows someone.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.