Skip to content

Commit

Permalink
Time: 17 ms (61.03%), Space: 20.3 MB (14.61%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipendra-Raghav committed May 13, 2023
1 parent c1adc83 commit cc378fb
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
#define ll long long
public:
ll mod=1e9+7;
ll c(ll len,ll low,ll high,vector<ll>&dp,int zero,int one){
if(len>high)return 0;
if(dp[len]!=-1)return dp[len];
ll ans=0;
if(len>=low && len<=high)ans=1;
ans += c(len+zero,low,high,dp,zero,one)%mod;
ans = (ans%mod + c(len+one,low,high,dp,zero,one)%mod)%mod;
dp[len]=ans;
return ans;
}
int countGoodStrings(int low, int high, int zero, int one) {
vector<ll>dp(high+1,-1);
return c(0,low,high,dp,zero,one);
}
};

0 comments on commit cc378fb

Please sign in to comment.