Secret Santa problem | How to solve this?
Anonymous User
6340

I was given this question in an amazon interview:

Imagine that every year your extended family does a "Secret Santa" gift exchange. For this gift exchange, each person draws another person at random and then gets a gift for them. Families usually get gifts for members of their immediate family, so it doesn’t make a lot of sense for anyone to be a Secret Santa for a member of their immediate family (spouse, parents, or children). Write a program that will choose a Secret Santa for everyone given a list of all the members of your extended family. Obviously, a person cannot be their own Secret Santa.

It is easy to find the gift for each other without the constraint ( just shift the array ) but I am not able to find the right solution given that you cannot gift to immediate family. I can use some help.

Comments (4)