dp
of size high + 1
with all elements set to 0.dp[0]
to 1, as the empty string is a valid starting point.i
from 1 to high
:
i >= zero
, increment dp[i]
by dp[i - zero]
.i >= one
, increment dp[i]
by dp[i - one]
.dp
array, sum up the values from dp[low]
to dp[high]
to get the total count.10^9 + 7
.