Back to problems

Number of Ways to Wear Different Hats to Each Other

Algorithm · Roblox · Hard

Problem: Count the Ways People Can Receive Unique Hats You have n individuals labeled from 0 through n - 1. A hat is identified by a positive integer, and person i may choose only from the hats listed in hats[i]. Determine how many assignments satisfy all of these conditions: Every person is assigned one and only one hat. A hat cannot be assigned to more than one person. The hat selected for person i must appear in hats[i]. Report the result modulo 10^9 + 7. The interviewer…

Checking your access…