On day 1, one person discovers a secret.

You are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the secret. You are also given an integer forget, which means that each person will forget the secret forget days after discovering it. A person cannot share the secret on the same day they forgot it, or on any day afterwards.

Given an integer n, return the number of people who know the secret at the end of day n. Since the answer may be very large, return it modulo 109 + 7.

&nbsp;
Example 1:

Input: n = 6, delay = 2, forget = 4
Output: 5
Explanation:
Day 1: Suppose the first person is named A. (1 person)
Day 2: A is the only person who knows the secret. (1 person)
Day 3: A shares the secret with a new person, B. (2 people)
Day 4: A shares the secret with a new person, C. (3 people)
Day 5: A forgets the secret, and B shares the secret with a new person, D. (3 people)
Day 6: B shares the secret with E, and C shares the secret with F. (5 people)


Example 2:

Input: n = 4, delay = 1, forget = 3
Output: 6
Explanation:
Day 1: The first person is named A. (1 person)
Day 2: A shares the secret with B. (2 people)
Day 3: A and B share the secret with 2 new people, C and D. (4 people)
Day 4: A forgets the secret. B, C, and D share the secret with 3 new people. (6 people)


&nbsp;
Constraints:


	2 &lt;= n &lt;= 1000
	1 &lt;= delay &lt; forget &lt;= n


```class Solution:
    def peopleAwareOfSecret(self, n: int, delay: int, forget: int) -> int:
        table = [0]*(forget+1)
        table[1] = 1
        days = 1
        while days<=n-1:
            count = 0
            for k in range(forget-1,-1,-1):
                if k+1>delay:
                    table[k+1] = table[k]
                    count+=table[k]
                elif k+1<=delay:
                    table[k+1] = table[k]
            table[1] = count
            days+=1
        count = 0
        for k in range(1,forget+1):
            count+=table[k]
        return count%(pow(10,9)+7)
		
TC---O(forget*n)
sc---O(forget)
            
class Solution {
    public int peopleAwareOfSecret(int n, int delay, int forget) {
        long mod = 1000000007L;
        long[] shares = new long[n + 1];
        long[] forgets = new long[n + 1];

        if (delay < n) {
            shares[delay + 1] = 1;
        }
        if (forget < n) {
            forgets[forget + 1] = 1;
        }

        long shareToday = 0;
        long peopleKnow = 1;
        for (int i = delay; i <= n; i++) {
            shareToday += shares[i] % mod;
            shareToday -= forgets[i] % mod;

            peopleKnow -= forgets[i] % mod;
            peopleKnow += shareToday % mod;

            if (i + delay < n + 1) {
                shares[i + delay] += shareToday % mod;
            }
            if (i + forget < n + 1) {
                forgets[i + forget] += shareToday % mod;
            }
        }

        return (int) (peopleKnow % mod);
    }
}
static int MOD=1e9+7;
class Solution {
public:
    int delay,forget;
    vector<long> memo;
    // Total number of people who would have found out about the secret by the nth day.
    long dp(int n) {
        if(!n)
            return 0;
        if(memo[n]!=-1)  // Return cached result if exists.
            return memo[n];
		// Current contribution of 1 person who knows the secret
        long result=1;
        for(int i=delay;i<forget;i++)       // Number of people that the secret will be forwarded to
            if(n-i>=0)
                result=(result+dp(n-i))%MOD;
        return memo[n]=result;
    }
    int peopleAwareOfSecret(int n, int delay, int forget) {
        this->delay=delay;
        this->forget=forget;
        memo.resize(n+1,-1);
        return (dp(n)-dp(n-forget)+MOD)%MOD;    // Subtract the people who found out by the `n-forget` day as observed.
    }
};
/**
 * @param {number} n
 * @param {number} delay
 * @param {number} forget
 * @return {number}
 */
var peopleAwareOfSecret = function(n, delay, forget) {
    const dp=new Array(n+1).fill(0);
    let numberOfPeopleSharingSecret = 0;
    let totalNumberOfPeopleWithSecret = 0;
    const MOD = 1000000007n;
    
    dp[1]=1; // as on day one only one person knows the secret
    
    for(let i=2;i<=n;i++){
        const numberOfNewPeopleSharingSecret = dp[Math.max(i-delay,0)];
        const numberOfPeopleForgettingSecret = dp[Math.max(i-forget,0)];
        numberOfPeopleSharingSecret = BigInt(numberOfPeopleSharingSecret) + 
            (   BigInt(numberOfNewPeopleSharingSecret) 
              - BigInt(numberOfPeopleForgettingSecret) 
              + BigInt(MOD)
            ) % BigInt(MOD);
        
        dp[i] = numberOfPeopleSharingSecret;
    }
    
    for(let i=n-forget+1;i<=n;i++){
       totalNumberOfPeopleWithSecret = 
           (BigInt(totalNumberOfPeopleWithSecret) + BigInt(dp[i])) % BigInt(MOD); 
    }
    
    return totalNumberOfPeopleWithSecret;
};
Number of People Aware of a Secret