Skip to content
Discussion options

You must be logged in to vote

We need to determine the number of people who know a secret by the end of day n, considering that each person shares the secret with a new person every day starting from delay days after discovering it, and forgets the secret forget days after discovering it. The challenge is to model the propagation and forgetting of the secret over time efficiently.

Approach

  1. Dynamic Programming (DP) Setup: We use a DP array dp where dp[i] represents the number of people who discover the secret on day i.
  2. Initialization: On day 1, one person discovers the secret, so dp[1] = 1.
  3. Propagation Calculation: For each subsequent day i (from 2 to n), the number of new people who discover the secret is the sum of …

Replies: 1 comment 2 replies

Comment options

mah-shamim
Sep 9, 2025
Maintainer Author

You must be logged in to vote
2 replies
@basharul-siddike
Comment options

@mah-shamim
Comment options

mah-shamim Sep 9, 2025
Maintainer Author

Answer selected by basharul-siddike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants