t behaves the same way:
- starting on day t + delay, they tell the rumor to one new person every day;
- on day t + forget they forget it, and from that day on they tell no one and no longer count as knowing it.
Return how many people know the rumor at the end of day days. The answer can be large, so return it modulo 10⁹ + 7.days=5, delay=2, forget=4 → 3
Day 1: A knows. Day 3: A tells B. Day 4: A tells C while B is still waiting. Day 5: A forgets, B tells D, C is still waiting. At the end of day 5, B, C and D know, which is three people.
days=3, delay=1, forget=2 → 2
Day 2: the first person tells a second. Day 3: the first forgets while the second tells a third. At the end of day 3, two people know: the second and the third.
days=5, delay=2, forget=4
3
Run checks the first 3 tests in your browser. Submit checks all 98 tests on the server, hidden ones included.