TheRealSamuel/LeetCodeProblem
0572
1{2 "id": 2562,3 "name": "count_ways_to_build_good_strings",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/count-ways-to-build-good-strings/",6 "date": "1667001600000",7 "task_description": "Given the integers `zero`, `one`, `low`, and `high`, we can construct a string by starting with an empty string, and then at each step perform either of the following: Append the character `'0'` `zero` times. Append the character `'1'` `one` times. This can be performed any number of times. A **good** string is a string constructed by the above process having a **length** between `low` and `high` (**inclusive**). Return _the number of **different** good strings that can be constructed satisfying these properties._ Since the answer can be large, return it **modulo** `109 + 7`. **Example 1:** ``` **Input:** low = 3, high = 3, zero = 1, one = 1 **Output:** 8 **Explanation:** One possible valid good string is \"011\". It can be constructed as follows: \"\" -> \"0\" -> \"01\" -> \"011\". All binary strings from \"000\" to \"111\" are good strings in this example. ``` **Example 2:** ``` **Input:** low = 2, high = 3, zero = 1, one = 2 **Output:** 5 **Explanation:** The good strings are \"00\", \"11\", \"000\", \"110\", and \"011\". ``` **Constraints:** `1 <= low <= high <= 105` `1 <= zero, one <= low`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "low = 3, high = 3, zero = 1, one = 1",12 "output": "8 "13 },14 {15 "label": "Example 2",16 "input": "low = 2, high = 3, zero = 1, one = 2",17 "output": "5 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 43516,24 53594,25 36914,26 856327 ],28 "output": 329 },30 {31 "input": [32 22795,33 79620,34 5950,35 1782136 ],37 "output": 27138 },39 {40 "input": [41 44226,42 61537,43 1112,44 582045 ],46 "output": 638605547 },48 {49 "input": [50 54729,51 88024,52 33857,53 365154 ],55 "output": 16556 },57 {58 "input": [59 72028,60 86808,61 34039,62 6225063 ],64 "output": 065 },66 {67 "input": [68 14697,69 66644,70 7822,71 1437072 ],73 "output": 11074 },75 {76 "input": [77 77737,78 96641,79 12337,80 1768281 ],82 "output": 7083 },84 {85 "input": [86 33570,87 41074,88 25499,89 2425890 ],91 "output": 092 },93 {94 "input": [95 92099,96 92587,97 57439,98 7399599 ],100 "output": 0101 },102 {103 "input": [104 59859,105 94179,106 21463,107 2717108 ],109 "output": 2573110 }111 ],112 "haskell_template": "countGoodStrings :: Int -> Int -> Int -> Int -> Int\ncountGoodStrings low high zero one ",113 "ocaml_template": "let countGoodStrings (low: int) (high: int) (zero: int) (one: int) : int = ",114 "scala_template": "def countGoodStrings(low: Int,high: Int,zero: Int,one: Int): Int = { \n \n}",115 "java_template": "public static int countGoodStrings(int low, int high, int zero, int one) {\n\n}",116 "python_template": "class Solution(object):\n def countGoodStrings(self, low, high, zero, one):\n \"\"\"\n :type low: int\n :type high: int\n :type zero: int\n :type one: int\n :rtype: int\n \"\"\"\n "117}