Salesforce interview problem

687
Aug 01, 2023
Aug 01, 2023

Alice is having a small pond in her vilage. Initially there are 0 frogs in the pond. One day she brings a frog of special race and leaves it in the pond. The frog's race is having some properties which are as follows-

1. A frog will start reproducing another frog each day after X days of its birth.
2. A frog will die after Y days i.e. on (Y+1)th day after its birth.
3. A frog can't reproduce another frog on/afterwards the day in which it will die.

Alice wants to know how many frogs are alive after N days.

Return total numbers of alive frogs after N days
Please return answer modulo 10^9+7
1<=N<=10^5
1<=X<Y<=10^5

eg:-
N=5
X=1
Y=3
ans:=10

N=5
X=2
Y=3
ans:=2

N=3
X=1
Y=2
ans=2

Comments (6)