← All problemsSign in

We are Friends 3

There Are $N$ houses connected with $N-1$ roads (Depicting a tree). Jonesy Lives in house $1$ so this can be considered as the root of the tree. Now there are $K$ friends who want to be the best friend of Jonesy. He will be the best friend of one who lives at a minimum distance from the house. Now the distance between the two houses is the number of roads between them. If two or more

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