← All problemsSign in

The Social Network

A group of friends is formed if all members of the group are somehow connected. So, in a group of friends, there is always some path from member a to member b, for all members a and b belonging to the group. You will be given the friendship status of n people. You are to determine whether two persons, a and b (among those n people), given as queries, belong to the same group or not. Input The

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start