Search⌘ K
AI Features

Number of People Aware of a Secret

Explore how to solve a dynamic programming problem that involves tracking the spread and forgetting of a secret over days. Learn to use memoization and modular arithmetic to efficiently determine the number of people aware of the secret on day n, considering delay and forget periods.

Statement

On day 11, exactly one person discovers a secret.

Each person who learns the secret will begin sharing it with one new person every day, but only after a waiting period of delay days from when they first discovered it. Additionally, each person completely forgets the secret forget days after discovering it. Once a person has forgotten the secret (on the day of forgetting and all subsequent days), they can no longer share it.

Given an integer n, determine how many people know the secret at the end of day n. Since the result can be very large, return it modulo ...