n
, done
, MOD
, memo
, and hatsToPeople
.hatsToPeople
with the preferences of each person.dp(hat, mask)
.
mask == done
, return 1.hat > 40
, return 0.memo[hat][mask]
is calculated, return its value.dp(hat, mask)
.dp(1, 0)
as the final answer.