CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes564downloads
1{2    "id": 3406,3    "name": "find_all_possible_stable_binary_arrays_i",4    "difficulty": "Medium",5    "link": "https://leetcode.com/problems/find-all-possible-stable-binary-arrays-i/",6    "date": "2024-04-13 00:00:00",7    "task_description": "You are given 3 positive integers `zero`, `one`, and `limit`. A binary array `arr` is called **stable** if: The number of occurrences of 0 in `arr` is **exactly **`zero`. The number of occurrences of 1 in `arr` is **exactly** `one`. Each subarray of `arr` with a size greater than `limit` must contain **both **0 and 1. Return the _total_ number of **stable** binary arrays. Since the answer may be very large, return it **modulo** `109 + 7`. **Example 1:** **Input:** zero = 1, one = 1, limit = 2 **Output:** 2 **Explanation:** The two possible stable binary arrays are `[1,0]` and `[0,1]`, as both arrays have a single 0 and a single 1, and no subarray has a length greater than 2. **Example 2:** **Input:** zero = 1, one = 2, limit = 1 **Output:** 1 **Explanation:** The only possible stable binary array is `[1,0,1]`. Note that the binary arrays `[1,1,0]` and `[0,1,1]` have subarrays of length 2 with identical elements, hence, they are not stable. **Example 3:** **Input:** zero = 3, one = 3, limit = 2 **Output:** 14 **Explanation:** All the possible stable binary arrays are `[0,0,1,0,1,1]`, `[0,0,1,1,0,1]`, `[0,1,0,0,1,1]`, `[0,1,0,1,0,1]`, `[0,1,0,1,1,0]`, `[0,1,1,0,0,1]`, `[0,1,1,0,1,0]`, `[1,0,0,1,0,1]`, `[1,0,0,1,1,0]`, `[1,0,1,0,0,1]`, `[1,0,1,0,1,0]`, `[1,0,1,1,0,0]`, `[1,1,0,0,1,0]`, and `[1,1,0,1,0,0]`. **Constraints:** `1 <= zero, one, limit <= 200`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "zero = 1, one = 1, limit = 2",12            "output": "2 "13        },14        {15            "label": "Example 2",16            "input": "zero = 1, one = 2, limit = 1",17            "output": "1 "18        },19        {20            "label": "Example 3",21            "input": "zero = 3, one = 3, limit = 2",22            "output": "14 "23        }24    ],25    "private_test_cases": [26        {27            "input": [28                185,29                61,30                8831            ],32            "output": 86086445533        },34        {35            "input": [36                172,37                150,38                9239            ],40            "output": 58664521241        },42        {43            "input": [44                164,45                135,46                13147            ],48            "output": 65602474649        },50        {51            "input": [52                43,53                100,54                7255            ],56            "output": 66224792257        },58        {59            "input": [60                177,61                160,62                17563            ],64            "output": 24271084765        },66        {67            "input": [68                39,69                37,70                12771            ],72            "output": 4748093573        },74        {75            "input": [76                92,77                123,78                7079            ],80            "output": 88918423781        },82        {83            "input": [84                160,85                148,86                10487            ],88            "output": 72124883389        },90        {91            "input": [92                33,93                33,94                8095            ],96            "output": 48026705997        },98        {99            "input": [100                133,101                161,102                26103            ],104            "output": 396166895105        }106    ],107    "haskell_template": "numberOfStableArrays :: Int -> Int -> Int -> Int\nnumberOfStableArrays zero one limit ",108    "ocaml_template": "let numberOfStableArrays (zero: int) (one: int) (limit: int) : int =  ",109    "scala_template": "def numberOfStableArrays(zero: Int,one: Int,limit: Int): Int = { \n    \n}",110    "java_template": "class Solution {\n    public int numberOfStableArrays(int zero, int one, int limit) {\n        \n    }\n}",111    "python_template": "class Solution(object):\n    def numberOfStableArrays(self, zero, one, limit):\n        \"\"\"\n        :type zero: int\n        :type one: int\n        :type limit: int\n        :rtype: int\n        \"\"\"\n        "112}