Skip to content

Commit 12c0f3d

Browse files
committed
2466
1 parent 13a2c12 commit 12c0f3d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# @param {Integer} low
2+
# @param {Integer} high
3+
# @param {Integer} zero
4+
# @param {Integer} one
5+
# @return {Integer}
6+
def count_good_strings(low, high, zero, one)
7+
mod = 1000000007
8+
dp = Array.new(high + 1, 0)
9+
dp[0] = 1
10+
(1..high).each { |i|
11+
dp[i] = (dp[i] + dp[i - zero]) % mod if i - zero >= 0
12+
dp[i] = (dp[i] + dp[i - one]) % mod if i - one >= 0
13+
}
14+
15+
dp[low..high].sum % mod
16+
end

0 commit comments

Comments
 (0)