Skip to content

Commit c2d24d0

Browse files
Time: 18 ms (54.73%), Space: 20.2 MB (14.61%) - LeetHub
1 parent f24507f commit c2d24d0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
#define ll long long
3+
public:
4+
ll mod=1e9+7;
5+
ll c(ll len,ll low,ll high,vector<ll>&dp,int zero,int one){
6+
if(len>high)return 0;
7+
if(dp[len]!=-1)return dp[len];
8+
ll ans=0;
9+
if(len>=low && len<=high)ans=1;
10+
ans += c(len+zero,low,high,dp,zero,one)%mod;
11+
ans = (ans%mod + c(len+one,low,high,dp,zero,one)%mod)%mod;
12+
dp[len]=ans;
13+
return ans;
14+
}
15+
int countGoodStrings(int low, int high, int zero, int one) {
16+
vector<ll>dp(high+1,-1);
17+
return c(0,low,high,dp,zero,one);
18+
}
19+
};

0 commit comments

Comments
 (0)