← Questions

Count connected friend groups

0
OpenAICodingLast asked Jul 2026

Given people and the friendships between them, count the friend groups: two people are in the same group when they are friends, directly or through a chain of friends. Solve it with a graph traversal or union-find and give the time and space.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding