Solution to Leetcode problem Count Ways To Build Good Strings in C++
1class Solution {
2public:
3 int countGoodStrings(int low, int high, int zero, int one) {
4 int dp[high+1];
5 memset(dp, 0, sizeof(dp));
6 dp[0]=1;
7 int ans=0;
8 for(int i=1;i<=high;i++){
9 dp[i] = ((i-zero>=0 ? dp[i-zero]:0)+(i-one>=0 ? dp[i-one]:0))%1000000007;
10 if(i>=low){
11 ans = (ans+dp[i])%1000000007;
12 }
13 }
14 return ans;
15 }
16};
The legendary fast inverse square root implementation from Quake III Arena source code with the original comment text.
The legendary fast inverse square root implementation from Quake III Arena source code with the original comment text.