## Inverse permutation problem

This problem is from code forces. If you want to try this problem, follow this link. Here is the simplified problem statement. Given a group of N friends, each one has given a gift to other friend or themselves. An input array is given which indicates from whom each one has received their gifts. We…