정수형 데이터 4개를 받는데 low, high는 만들어질 문자열의 최소, 최대 길이이며,
zero와 one은 "0"으로 이루어진 문자열의 길이와 "1"으로 이루어진 문자열의 길이이다
zero와 one을 조합하여 low 이상 high 이하 길이를 가지는 문자열을 몇 개나 만들 수 있는지 구하는 문제
class Solution {
public:
const static int Modulo = 1e9 + 7;
int countGoodStrings(int low, int high, int zero, int one) {
vector<int> memo(high + 1, 0);
memo[0] = 1;
int temp{};
int nextZero{};
int nextOne{};
for (int i = 1; i <= high; ++i)
{
temp = i - zero;
if (0 <= temp)
{
nextZero = memo[temp];
}
temp = i - one;
if (0 <= temp)
{
nextOne = memo[temp];
}
memo[i] = (nextZero + nextOne) % Modulo;
}
temp = 0;
for (int i = low; i <= high; ++i)
{
temp += memo[i];
temp %= Modulo;
}
return temp;
}
};