Solution to Leetcode problem Count Ways To Build Good Strings in Java.
1class Solution {
2 public int countGoodStrings(int low, int high, int zero, int one) {
3 int dp[] = new int[high+1];
4 dp[0]=1;
5 int ans=0;
6 for(int i=1;i<=high;i++){
7 dp[i] = ((i-zero>=0 ? dp[i-zero]:0)+(i-one>=0 ? dp[i-one]:0))%1000000007;
8 if(i>=low){
9 ans = (ans+dp[i])%1000000007;
10 }
11 }
12 return ans;
13 }
14}
Solution to Leetcode problem Count Ways To Build Good Strings in Java.