Interview Questions/Coding/Active Memo Readers

Active Memo Readers

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Active Memo Readers

On day 1, one employee receives a private memo. An employee starts forwarding the memo wait days after receiving it and stops forwarding it expire days after receiving it. Once they stop, they no longer count as aware of the memo. Return how many employees are still aware of the memo at the end of day days. Return the answer modulo 10^9 + 7.

Examples

Example 1
Input:
days = 6, wait = 2, expire = 4
Output:
5

Approach hint

Group people by the day they first receive the memo.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp