Solution to Leetcode problem Count Ways To Build Good Strings in Python.
1class Solution:
2 def countGoodStrings(self, low: int, high: int, zero: int, one: int) -> int:
3 dp = [0] * (high+1)
4 dp[0] = 1
5 ans = 0
6 for i in range(1, high+1):
7 dp[i] = ((dp[i-zero] if i-zero>=0 else 0) + (dp[i-one] if i-one>=0 else 0)) % 1000000007
8 if i >= low:
9 ans = (ans + dp[i]) % 1000000007
10 return ans
Solution to "Count Number of Texts" question on Leetcode.
Solution to "Second Minimum Node In a Binary Tree" on Leetcode.