The insight: you need to reverse the direction of the relationship. The input tells you "person gave to person If friend gave to friend This pattern shows up in many problems.
When you have a mapping from to , and you need the reverse mapping from to , use the value as an index. This is a core array manipulation technique. This insight transforms a complex-looking problem into a manageable one.
Without it, you might overcomplicate the solution or miss edge cases. Look for this pattern in similar problems. Recognizing it quickly will help you solve problems faster in contests and interviews.