maximum-beauty-of-an-array-after-applying-operation

Maximum Beauty of an Array After Applying Operation

Prompt:
"""
给你一个下标从 0 开始的整数数组 nums 和一个 非负 整数 k 。

在一步操作中，你可以执行下述指令：

 * 在范围 [0, nums.length - 1] 中选择一个 此前没有选过 的下标 i 。
 * 将 nums[i] 替换为范围 [nums[i] - k, nums[i] + k] 内的任一整数。

数组的 美丽值 定义为数组中由相等元素组成的最长子序列的长度。

对数组 nums 执行上述操作任意次后，返回数组可能取得的 最大 美丽值。

注意：你 只 能对每个下标执行 一次 此操作。

数组的 子序列 定义是：经由原数组删除一些元素（也可能不删除）得到的一个新数组，且在此过程中剩余元素的顺序不发生改变。

示例 1：

输入：nums = [4,6,1,2], k = 2
输出：3
解释：在这个示例中，我们执行下述操作：
- 选择下标 1 ，将其替换为 4（从范围 [4,8] 中选出），此时 nums = [4,4,1,2] 。
- 选择下标 3 ，将其替换为 4（从范围 [0,4] 中选出），此时 nums = [4,4,1,4] 。
执行上述操作后，数组的美丽值是 3（子序列由下标 0 、1 、3 对应的元素组成）。
可以证明 3 是我们可以得到的由相等元素组成的最长子序列长度。

示例 2：

输入：nums = [1,1,1,1], k = 10
输出：4
解释：在这个示例中，我们无需执行任何操作。
数组 nums 的美丽值是 4（整个数组）。

提示：

 * 1 <= nums.length <= 105
 * 0 <= nums[i], k <= 105
"""
class Solution:
    def maximumBeauty(self, nums: List[int], k: int) -> int:

给你一个下标从 0 开始的整数数组 nums 和一个 非负 整数 k 。

在一步操作中，你可以执行下述指令：

 * 在范围 [0, nums.length - 1] 中选择一个 此前没有选过 的下标 i 。
 * 将 nums[i] 替换为范围 [nums[i] - k, nums[i] + k] 内的任一整数。

数组的 美丽值 定义为数组中由相等元素组成的最长子序列的长度。

对数组 nums 执行上述操作任意次后，返回数组可能取得的 最大 美丽值。

注意：你 只 能对每个下标执行 一次 此操作。

数组的 子序列 定义是：经由原数组删除一些元素（也可能不删除）得到的一个新数组，且在此过程中剩余元素的顺序不发生改变。

示例 1：

输入：nums = [4,6,1,2], k = 2
输出：3
解释：在这个示例中，我们执行下述操作：
- 选择下标 1 ，将其替换为 4（从范围 [4,8] 中选出），此时 nums = [4,4,1,2] 。
- 选择下标 3 ，将其替换为 4（从范围 [0,4] 中选出），此时 nums = [4,4,1,4] 。
执行上述操作后，数组的美丽值是 3（子序列由下标 0 、1 、3 对应的元素组成）。
可以证明 3 是我们可以得到的由相等元素组成的最长子序列长度。

示例 2：

输入：nums = [1,1,1,1], k = 10
输出：4
解释：在这个示例中，我们无需执行任何操作。
数组 nums 的美丽值是 4（整个数组）。

提示：

 * 1 <= nums.length <= 105
 * 0 <= nums[i], k <= 105

请完成下面的代码来解决上述问题:
```python
class Solution:
    def maximumBeauty(self, nums: List[int], k: int) -> int:

```

my_solution = Solution()

test_input = { "nums": [4,6,1,2], "k": 2 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [1,1,1,1], "k": 10 }
assert my_solution.maximumBeauty(**test_input) == 4

test_input = { "nums": [12,71], "k": 10 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [27,55], "k": 1 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [52,34], "k": 21 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [76,0], "k": 16 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [56,40], "k": 26 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [49,26], "k": 12 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [69,66], "k": 14 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [64,98], "k": 12 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [83,81], "k": 7 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [44,93], "k": 15 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [44,31], "k": 26 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [70,60], "k": 15 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [60,22], "k": 11 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [33,20], "k": 1 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [64,24], "k": 4 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [59,20], "k": 28 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [10,98], "k": 27 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [54,21], "k": 20 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [61,11], "k": 15 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [99,40], "k": 27 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [32,91], "k": 3 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [91,57], "k": 21 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [60,92], "k": 26 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [4,45], "k": 6 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [24,35], "k": 6 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [11,29], "k": 3 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [51,29], "k": 3 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [43,21], "k": 14 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [32,25], "k": 18 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [13,66], "k": 5 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [89,71], "k": 28 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [36,29], "k": 20 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [11,43], "k": 21 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [15,36], "k": 4 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [11,51], "k": 1 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [2,57], "k": 20 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [94,66], "k": 26 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [87,51], "k": 8 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [5,57,46], "k": 15 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [81,46,85], "k": 23 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [51,83,0], "k": 11 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [75,15,9], "k": 28 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [10,59,86], "k": 23 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [41,11,59], "k": 17 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [62,77,100], "k": 5 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [27,35,15], "k": 6 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [81,76,40], "k": 5 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [84,43,96], "k": 7 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [62,1,93], "k": 30 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [13,46,71], "k": 29 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [92,99,44], "k": 28 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [73,30,40], "k": 26 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [83,89,17], "k": 5 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [38,20,11], "k": 9 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [63,56,23], "k": 14 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [32,16,98], "k": 0 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [57,58,71], "k": 2 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [61,50,35], "k": 2 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [22,97,13], "k": 22 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [89,52,33], "k": 14 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [89,4,77], "k": 20 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [50,26,72], "k": 30 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [72,75,47], "k": 7 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [23,1,73], "k": 25 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [36,74,20], "k": 20 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [34,64,11], "k": 18 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [29,94,45], "k": 27 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [22,80,34], "k": 28 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [52,63,75], "k": 11 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [53,63,93,89], "k": 23 }
assert my_solution.maximumBeauty(**test_input) == 4

test_input = { "nums": [47,76,100,51], "k": 27 }
assert my_solution.maximumBeauty(**test_input) == 4

test_input = { "nums": [73,83,46,88], "k": 13 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [50,28,30,51], "k": 2 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [88,87,9,17], "k": 10 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [27,56,27,40], "k": 6 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [88,19,2,30], "k": 6 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [58,50,0,97], "k": 18 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [83,10,99,99], "k": 18 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [58,75,1,25], "k": 12 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [77,35,1,69], "k": 15 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [23,33,62,20], "k": 12 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [42,34,18,0], "k": 5 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [10,58,37,46], "k": 0 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [34,73,57,55], "k": 27 }
assert my_solution.maximumBeauty(**test_input) == 4

test_input = { "nums": [53,100,74,5], "k": 4 }
assert my_solution.maximumBeauty(**test_input) == 1

test_input = { "nums": [48,93,96,19], "k": 24 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [91,12,29,31], "k": 22 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [48,9,35,36], "k": 12 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [24,64,40,30], "k": 3 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [19,58,41,42], "k": 14 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [72,44,29,76], "k": 4 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [37,19,10,16], "k": 16 }
assert my_solution.maximumBeauty(**test_input) == 4

test_input = { "nums": [54,84,73,31], "k": 30 }
assert my_solution.maximumBeauty(**test_input) == 4

test_input = { "nums": [83,92,30,60], "k": 19 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [14,51,99,64], "k": 15 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [7,60,16,2], "k": 17 }
assert my_solution.maximumBeauty(**test_input) == 3

test_input = { "nums": [7,89,54,54], "k": 5 }
assert my_solution.maximumBeauty(**test_input) == 2

test_input = { "nums": [43,86,33,18], "k": 23 }
assert my_solution.maximumBeauty(**test_input) == 3


minimum-index-of-a-valid-split

Minimum Index of a Valid Split

Prompt:
"""
如果元素 x 在长度为 m 的整数数组 arr 中满足 freq(x) * 2 > m ，那么我们称 x 是 支配元素 。其中 freq(x) 是 x 在数组 arr 中出现的次数。注意，根据这个定义，数组 arr 最多 只会有 一个 支配元素。

给你一个下标从 0 开始长度为 n 的整数数组 nums ，数据保证它含有一个支配元素。

你需要在下标 i 处将 nums 分割成两个数组 nums[0, ..., i] 和 nums[i + 1, ..., n - 1] ，如果一个分割满足以下条件，我们称它是 合法 的：

 * 0 <= i < n - 1
 * nums[0, ..., i] 和 nums[i + 1, ..., n - 1] 的支配元素相同。

这里， nums[i, ..., j] 表示 nums 的一个子数组，它开始于下标 i ，结束于下标 j ，两个端点都包含在子数组内。特别地，如果 j < i ，那么 nums[i, ..., j] 表示一个空数组。

请你返回一个 合法分割 的 最小 下标。如果合法分割不存在，返回 -1 。

示例 1：

输入：nums = [1,2,2,2]
输出：2
解释：我们将数组在下标 2 处分割，得到 [1,2,2] 和 [2] 。
数组 [1,2,2] 中，元素 2 是支配元素，因为它在数组中出现了 2 次，且 2 * 2 > 3 。
数组 [2] 中，元素 2 是支配元素，因为它在数组中出现了 1 次，且 1 * 2 > 1 。
两个数组 [1,2,2] 和 [2] 都有与 nums 一样的支配元素，所以这是一个合法分割。
下标 2 是合法分割中的最小下标。

示例 2：

输入：nums = [2,1,3,1,1,1,7,1,2,1]
输出：4
解释：我们将数组在下标 4 处分割，得到 [2,1,3,1,1] 和 [1,7,1,2,1] 。
数组 [2,1,3,1,1] 中，元素 1 是支配元素，因为它在数组中出现了 3 次，且 3 * 2 > 5 。
数组 [1,7,1,2,1] 中，元素 1 是支配元素，因为它在数组中出现了 3 次，且 3 * 2 > 5 。
两个数组 [2,1,3,1,1] 和 [1,7,1,2,1] 都有与 nums 一样的支配元素，所以这是一个合法分割。
下标 4 是所有合法分割中的最小下标。

示例 3：

输入：nums = [3,3,3,3,7,2,2]
输出：-1
解释：没有合法分割。

提示：

 * 1 <= nums.length <= 105
 * 1 <= nums[i] <= 109
 * nums 有且只有一个支配元素。
"""
class Solution:
    def minimumIndex(self, nums: List[int]) -> int:

如果元素 x 在长度为 m 的整数数组 arr 中满足 freq(x) * 2 > m ，那么我们称 x 是 支配元素 。其中 freq(x) 是 x 在数组 arr 中出现的次数。注意，根据这个定义，数组 arr 最多 只会有 一个 支配元素。

给你一个下标从 0 开始长度为 n 的整数数组 nums ，数据保证它含有一个支配元素。

你需要在下标 i 处将 nums 分割成两个数组 nums[0, ..., i] 和 nums[i + 1, ..., n - 1] ，如果一个分割满足以下条件，我们称它是 合法 的：

 * 0 <= i < n - 1
 * nums[0, ..., i] 和 nums[i + 1, ..., n - 1] 的支配元素相同。

这里， nums[i, ..., j] 表示 nums 的一个子数组，它开始于下标 i ，结束于下标 j ，两个端点都包含在子数组内。特别地，如果 j < i ，那么 nums[i, ..., j] 表示一个空数组。

请你返回一个 合法分割 的 最小 下标。如果合法分割不存在，返回 -1 。

示例 1：

输入：nums = [1,2,2,2]
输出：2
解释：我们将数组在下标 2 处分割，得到 [1,2,2] 和 [2] 。
数组 [1,2,2] 中，元素 2 是支配元素，因为它在数组中出现了 2 次，且 2 * 2 > 3 。
数组 [2] 中，元素 2 是支配元素，因为它在数组中出现了 1 次，且 1 * 2 > 1 。
两个数组 [1,2,2] 和 [2] 都有与 nums 一样的支配元素，所以这是一个合法分割。
下标 2 是合法分割中的最小下标。

示例 2：

输入：nums = [2,1,3,1,1,1,7,1,2,1]
输出：4
解释：我们将数组在下标 4 处分割，得到 [2,1,3,1,1] 和 [1,7,1,2,1] 。
数组 [2,1,3,1,1] 中，元素 1 是支配元素，因为它在数组中出现了 3 次，且 3 * 2 > 5 。
数组 [1,7,1,2,1] 中，元素 1 是支配元素，因为它在数组中出现了 3 次，且 3 * 2 > 5 。
两个数组 [2,1,3,1,1] 和 [1,7,1,2,1] 都有与 nums 一样的支配元素，所以这是一个合法分割。
下标 4 是所有合法分割中的最小下标。

示例 3：

输入：nums = [3,3,3,3,7,2,2]
输出：-1
解释：没有合法分割。

提示：

 * 1 <= nums.length <= 105
 * 1 <= nums[i] <= 109
 * nums 有且只有一个支配元素。

请完成下面的代码来解决上述问题:
```python
class Solution:
    def minimumIndex(self, nums: List[int]) -> int:

```

my_solution = Solution()

test_input = { "nums": [1,2,2,2] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [2,1,3,1,1,1,7,1,2,1] }
assert my_solution.minimumIndex(**test_input) == 4

test_input = { "nums": [3,3,3,3,7,2,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,1,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,1,1,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,1,1,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,1,1,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,1,1,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,1,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,1,2,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,1,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,1,3,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,1,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,1,4,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,2,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,2,1,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,2,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,3,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,3,1,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,3,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,3,3,3] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [1,4,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,4,1,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [1,4,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [1,4,4,4] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,1,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,1,1,1] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [2,1,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,1,2,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,2,1,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2,2,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2,2,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2,2,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2,2,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,2,3,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,2,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,2,4,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,3,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,3,2,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,3,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,3,3,3] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [2,4,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,4,2,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [2,4,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [2,4,4,4] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,1,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,1,1,1] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [3,1,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,1,3,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,2,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,2,2,2] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [3,2,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,2,3,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,3,1,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,3,2,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3,3,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3,3,2] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3,3,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3,3,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,3,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,3,4,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,4,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,4,3,3] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [3,4,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [3,4,4,4] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,1,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,1,1,1] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [4,1,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,1,4,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,2,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,2,2,2] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [4,2,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,2,4,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,3,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,3,3,3] }
assert my_solution.minimumIndex(**test_input) == 2

test_input = { "nums": [4,3,4] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,3,4,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,4,1] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,4,1,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,4,2] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,4,2,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,4,3] }
assert my_solution.minimumIndex(**test_input) == -1

test_input = { "nums": [4,4,3,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,4,4] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,4,4,1] }
assert my_solution.minimumIndex(**test_input) == 0

test_input = { "nums": [4,4,4,2] }
assert my_solution.minimumIndex(**test_input) == 0


length-of-the-longest-valid-substring

Length of the Longest Valid Substring

Prompt:
"""
给你一个字符串 word 和一个字符串数组 forbidden 。

如果一个字符串不包含 forbidden 中的任何字符串，我们称这个字符串是 合法 的。

请你返回字符串 word 的一个 最长合法子字符串 的长度。

子字符串 指的是一个字符串中一段连续的字符，它可以为空。

示例 1：

输入：word = "cbaaaabc", forbidden = ["aaa","cb"]
输出：4
解释：总共有 11 个合法子字符串："c", "b", "a", "ba", "aa", "bc", "baa", "aab", "ab", "abc" 和 "aabc"。最长合法子字符串的长度为 4 。
其他子字符串都要么包含 "aaa" ，要么包含 "cb" 。

示例 2：

输入：word = "leetcode", forbidden = ["de","le","e"]
输出：4
解释：总共有 11 个合法子字符串："l" ，"t" ，"c" ，"o" ，"d" ，"tc" ，"co" ，"od" ，"tco" ，"cod" 和 "tcod" 。最长合法子字符串的长度为 4 。
所有其他子字符串都至少包含 "de" ，"le" 和 "e" 之一。

提示：

 * 1 <= word.length <= 105
 * word 只包含小写英文字母。
 * 1 <= forbidden.length <= 105
 * 1 <= forbidden[i].length <= 10
 * forbidden[i] 只包含小写英文字母。
"""
class Solution:
    def longestValidSubstring(self, word: str, forbidden: List[str]) -> int:

给你一个字符串 word 和一个字符串数组 forbidden 。

如果一个字符串不包含 forbidden 中的任何字符串，我们称这个字符串是 合法 的。

请你返回字符串 word 的一个 最长合法子字符串 的长度。

子字符串 指的是一个字符串中一段连续的字符，它可以为空。

示例 1：

输入：word = "cbaaaabc", forbidden = ["aaa","cb"]
输出：4
解释：总共有 11 个合法子字符串："c", "b", "a", "ba", "aa", "bc", "baa", "aab", "ab", "abc" 和 "aabc"。最长合法子字符串的长度为 4 。
其他子字符串都要么包含 "aaa" ，要么包含 "cb" 。

示例 2：

输入：word = "leetcode", forbidden = ["de","le","e"]
输出：4
解释：总共有 11 个合法子字符串："l" ，"t" ，"c" ，"o" ，"d" ，"tc" ，"co" ，"od" ，"tco" ，"cod" 和 "tcod" 。最长合法子字符串的长度为 4 。
所有其他子字符串都至少包含 "de" ，"le" 和 "e" 之一。

提示：

 * 1 <= word.length <= 105
 * word 只包含小写英文字母。
 * 1 <= forbidden.length <= 105
 * 1 <= forbidden[i].length <= 10
 * forbidden[i] 只包含小写英文字母。

请完成下面的代码来解决上述问题:
```python
class Solution:
    def longestValidSubstring(self, word: str, forbidden: List[str]) -> int:

```

my_solution = Solution()

test_input = { "word": "cbaaaabc", "forbidden": ["aaa","cb"] }
assert my_solution.longestValidSubstring(**test_input) == 4

test_input = { "word": "leetcode", "forbidden": ["de","le","e"] }
assert my_solution.longestValidSubstring(**test_input) == 4

test_input = { "word": "a", "forbidden": ["n"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "a", "forbidden": ["s"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "a", "forbidden": ["a"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "b", "forbidden": ["g"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "b", "forbidden": ["t"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "b", "forbidden": ["b"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "c", "forbidden": ["k"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "c", "forbidden": ["s"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "c", "forbidden": ["c"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "d", "forbidden": ["h"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "d", "forbidden": ["n"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "d", "forbidden": ["d"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "e", "forbidden": ["s"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "e", "forbidden": ["e"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "f", "forbidden": ["b"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "f", "forbidden": ["s"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "f", "forbidden": ["f"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "g", "forbidden": ["r"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "g", "forbidden": ["y"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "g", "forbidden": ["g"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "h", "forbidden": ["v"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "h", "forbidden": ["b"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "h", "forbidden": ["h"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "i", "forbidden": ["k"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "i", "forbidden": ["y"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "i", "forbidden": ["i"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "j", "forbidden": ["v"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "j", "forbidden": ["u"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "j", "forbidden": ["j"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "k", "forbidden": ["z"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "k", "forbidden": ["o"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "k", "forbidden": ["k"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "l", "forbidden": ["i"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "l", "forbidden": ["r"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "l", "forbidden": ["l"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "m", "forbidden": ["s"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "m", "forbidden": ["g"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "m", "forbidden": ["m"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "n", "forbidden": ["e"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "n", "forbidden": ["i"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "n", "forbidden": ["n"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "o", "forbidden": ["j"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "o", "forbidden": ["f"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "o", "forbidden": ["o"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "p", "forbidden": ["z"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "p", "forbidden": ["i"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "p", "forbidden": ["p"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "q", "forbidden": ["j"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "q", "forbidden": ["z"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "q", "forbidden": ["q"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "r", "forbidden": ["v"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "r", "forbidden": ["p"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "r", "forbidden": ["r"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "s", "forbidden": ["m"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "s", "forbidden": ["x"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "s", "forbidden": ["s"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "t", "forbidden": ["v"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "t", "forbidden": ["m"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "t", "forbidden": ["t"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "u", "forbidden": ["l"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "u", "forbidden": ["n"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "u", "forbidden": ["u"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "v", "forbidden": ["o"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "v", "forbidden": ["v"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "w", "forbidden": ["w"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "w", "forbidden": ["s"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "x", "forbidden": ["r"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "x", "forbidden": ["q"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "x", "forbidden": ["x"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "y", "forbidden": ["w"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "y", "forbidden": ["t"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "y", "forbidden": ["y"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "z", "forbidden": ["l"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "z", "forbidden": ["o"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "z", "forbidden": ["z"] }
assert my_solution.longestValidSubstring(**test_input) == 0

test_input = { "word": "acbc", "forbidden": ["cbc","acb","acb","acbc"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "cabba", "forbidden": ["aaba","abba","acabb","cabb"] }
assert my_solution.longestValidSubstring(**test_input) == 3

test_input = { "word": "bbc", "forbidden": ["baba","babc","bbc","bbc"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "acb", "forbidden": ["acb","caccc","baaab","baa"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "aaac", "forbidden": ["aaac","aac","aaa","aaac"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "ca", "forbidden": ["ababa","ca","caac","babb"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "babbb", "forbidden": ["bbb","aacb","babbb","bcab"] }
assert my_solution.longestValidSubstring(**test_input) == 4

test_input = { "word": "cbbba", "forbidden": ["bca","cbbba","acbcc","aabb"] }
assert my_solution.longestValidSubstring(**test_input) == 4

test_input = { "word": "abab", "forbidden": ["aab","abab","cacb","bab"] }
assert my_solution.longestValidSubstring(**test_input) == 3

test_input = { "word": "cbab", "forbidden": ["bbcc","aaccc","cbab","babca"] }
assert my_solution.longestValidSubstring(**test_input) == 3

test_input = { "word": "caaa", "forbidden": ["aaa","cbb","aaa","caaa"] }
assert my_solution.longestValidSubstring(**test_input) == 3

test_input = { "word": "baa", "forbidden": ["aaab","bbaa","babac","baa"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "cbcc", "forbidden": ["cbcc","baa","bbba","cac"] }
assert my_solution.longestValidSubstring(**test_input) == 3

test_input = { "word": "cac", "forbidden": ["cccaa","baaca","cac","cac"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "cabab", "forbidden": ["cabab","abab","cabab","abab"] }
assert my_solution.longestValidSubstring(**test_input) == 4

test_input = { "word": "caa", "forbidden": ["caa","bba","acc","bcabb"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "ba", "forbidden": ["ba","ba","cab","cbcac"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "bbc", "forbidden": ["baca","bbc","bbc","caa"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "bbb", "forbidden": ["cbaab","bbb","bbb","bab"] }
assert my_solution.longestValidSubstring(**test_input) == 2

test_input = { "word": "bbccc", "forbidden": ["ccc","bcba","bcc","bcc"] }
assert my_solution.longestValidSubstring(**test_input) == 3

test_input = { "word": "bcac", "forbidden": ["bcac","caca","bcac","bca"] }
assert my_solution.longestValidSubstring(**test_input) == 3

test_input = { "word": "ab", "forbidden": ["aca","cabcc","caba","ab"] }
assert my_solution.longestValidSubstring(**test_input) == 1

test_input = { "word": "caa", "forbidden": ["bab","babbb","abbaa","caa"] }
assert my_solution.longestValidSubstring(**test_input) == 2


find-the-maximum-achievable-number

Find the Maximum Achievable Number

Prompt:
"""
给你两个整数 num 和 t 。

如果整数 x 可以在执行下述操作不超过 t 次的情况下变为与 num 相等，则称其为 可达成数字 ：

 * 每次操作将 x 的值增加或减少 1 ，同时可以选择将 num 的值增加或减少 1 。

返回所有可达成数字中的最大值。可以证明至少存在一个可达成数字。

示例 1：

输入：num = 4, t = 1
输出：6
解释：最大可达成数字是 x = 6 ，执行下述操作可以使其等于 num ：
- x 减少 1 ，同时 num 增加 1 。此时，x = 5 且 num = 5 。
可以证明不存在大于 6 的可达成数字。

示例 2：

输入：num = 3, t = 2
输出：7
解释：最大的可达成数字是 x = 7 ，执行下述操作可以使其等于 num ：
- x 减少 1 ，同时 num 增加 1 。此时，x = 6 且 num = 4 。
- x 减少 1 ，同时 num 增加 1 。此时，x = 5 且 num = 5 。
可以证明不存在大于 7 的可达成数字。

提示：

 * 1 <= num, t <= 50
"""
class Solution:
    def theMaximumAchievableX(self, num: int, t: int) -> int:

给你两个整数 num 和 t 。

如果整数 x 可以在执行下述操作不超过 t 次的情况下变为与 num 相等，则称其为 可达成数字 ：

 * 每次操作将 x 的值增加或减少 1 ，同时可以选择将 num 的值增加或减少 1 。

返回所有可达成数字中的最大值。可以证明至少存在一个可达成数字。

示例 1：

输入：num = 4, t = 1
输出：6
解释：最大可达成数字是 x = 6 ，执行下述操作可以使其等于 num ：
- x 减少 1 ，同时 num 增加 1 。此时，x = 5 且 num = 5 。
可以证明不存在大于 6 的可达成数字。

示例 2：

输入：num = 3, t = 2
输出：7
解释：最大的可达成数字是 x = 7 ，执行下述操作可以使其等于 num ：
- x 减少 1 ，同时 num 增加 1 。此时，x = 6 且 num = 4 。
- x 减少 1 ，同时 num 增加 1 。此时，x = 5 且 num = 5 。
可以证明不存在大于 7 的可达成数字。

提示：

 * 1 <= num, t <= 50

请完成下面的代码来解决上述问题:
```python
class Solution:
    def theMaximumAchievableX(self, num: int, t: int) -> int:

```

my_solution = Solution()

test_input = { "num": 4, "t": 1 }
assert my_solution.theMaximumAchievableX(**test_input) == 6

test_input = { "num": 3, "t": 2 }
assert my_solution.theMaximumAchievableX(**test_input) == 7

test_input = { "num": 1, "t": 1 }
assert my_solution.theMaximumAchievableX(**test_input) == 3

test_input = { "num": 1, "t": 2 }
assert my_solution.theMaximumAchievableX(**test_input) == 5

test_input = { "num": 1, "t": 3 }
assert my_solution.theMaximumAchievableX(**test_input) == 7

test_input = { "num": 1, "t": 4 }
assert my_solution.theMaximumAchievableX(**test_input) == 9

test_input = { "num": 1, "t": 5 }
assert my_solution.theMaximumAchievableX(**test_input) == 11

test_input = { "num": 1, "t": 6 }
assert my_solution.theMaximumAchievableX(**test_input) == 13

test_input = { "num": 1, "t": 7 }
assert my_solution.theMaximumAchievableX(**test_input) == 15

test_input = { "num": 1, "t": 8 }
assert my_solution.theMaximumAchievableX(**test_input) == 17

test_input = { "num": 1, "t": 9 }
assert my_solution.theMaximumAchievableX(**test_input) == 19

test_input = { "num": 1, "t": 10 }
assert my_solution.theMaximumAchievableX(**test_input) == 21

test_input = { "num": 1, "t": 11 }
assert my_solution.theMaximumAchievableX(**test_input) == 23

test_input = { "num": 1, "t": 12 }
assert my_solution.theMaximumAchievableX(**test_input) == 25

test_input = { "num": 1, "t": 13 }
assert my_solution.theMaximumAchievableX(**test_input) == 27

test_input = { "num": 1, "t": 14 }
assert my_solution.theMaximumAchievableX(**test_input) == 29

test_input = { "num": 1, "t": 15 }
assert my_solution.theMaximumAchievableX(**test_input) == 31

test_input = { "num": 1, "t": 16 }
assert my_solution.theMaximumAchievableX(**test_input) == 33

test_input = { "num": 1, "t": 17 }
assert my_solution.theMaximumAchievableX(**test_input) == 35

test_input = { "num": 1, "t": 18 }
assert my_solution.theMaximumAchievableX(**test_input) == 37

test_input = { "num": 1, "t": 19 }
assert my_solution.theMaximumAchievableX(**test_input) == 39

test_input = { "num": 1, "t": 20 }
assert my_solution.theMaximumAchievableX(**test_input) == 41

test_input = { "num": 1, "t": 21 }
assert my_solution.theMaximumAchievableX(**test_input) == 43

test_input = { "num": 1, "t": 22 }
assert my_solution.theMaximumAchievableX(**test_input) == 45

test_input = { "num": 1, "t": 23 }
assert my_solution.theMaximumAchievableX(**test_input) == 47

test_input = { "num": 1, "t": 24 }
assert my_solution.theMaximumAchievableX(**test_input) == 49

test_input = { "num": 1, "t": 25 }
assert my_solution.theMaximumAchievableX(**test_input) == 51

test_input = { "num": 1, "t": 26 }
assert my_solution.theMaximumAchievableX(**test_input) == 53

test_input = { "num": 1, "t": 27 }
assert my_solution.theMaximumAchievableX(**test_input) == 55

test_input = { "num": 1, "t": 28 }
assert my_solution.theMaximumAchievableX(**test_input) == 57

test_input = { "num": 1, "t": 29 }
assert my_solution.theMaximumAchievableX(**test_input) == 59

test_input = { "num": 1, "t": 30 }
assert my_solution.theMaximumAchievableX(**test_input) == 61

test_input = { "num": 1, "t": 31 }
assert my_solution.theMaximumAchievableX(**test_input) == 63

test_input = { "num": 1, "t": 32 }
assert my_solution.theMaximumAchievableX(**test_input) == 65

test_input = { "num": 1, "t": 33 }
assert my_solution.theMaximumAchievableX(**test_input) == 67

test_input = { "num": 1, "t": 34 }
assert my_solution.theMaximumAchievableX(**test_input) == 69

test_input = { "num": 1, "t": 35 }
assert my_solution.theMaximumAchievableX(**test_input) == 71

test_input = { "num": 1, "t": 36 }
assert my_solution.theMaximumAchievableX(**test_input) == 73

test_input = { "num": 1, "t": 37 }
assert my_solution.theMaximumAchievableX(**test_input) == 75

test_input = { "num": 1, "t": 38 }
assert my_solution.theMaximumAchievableX(**test_input) == 77

test_input = { "num": 1, "t": 39 }
assert my_solution.theMaximumAchievableX(**test_input) == 79

test_input = { "num": 1, "t": 40 }
assert my_solution.theMaximumAchievableX(**test_input) == 81

test_input = { "num": 1, "t": 41 }
assert my_solution.theMaximumAchievableX(**test_input) == 83

test_input = { "num": 1, "t": 42 }
assert my_solution.theMaximumAchievableX(**test_input) == 85

test_input = { "num": 1, "t": 43 }
assert my_solution.theMaximumAchievableX(**test_input) == 87

test_input = { "num": 1, "t": 44 }
assert my_solution.theMaximumAchievableX(**test_input) == 89

test_input = { "num": 1, "t": 45 }
assert my_solution.theMaximumAchievableX(**test_input) == 91

test_input = { "num": 1, "t": 46 }
assert my_solution.theMaximumAchievableX(**test_input) == 93

test_input = { "num": 1, "t": 47 }
assert my_solution.theMaximumAchievableX(**test_input) == 95

test_input = { "num": 1, "t": 48 }
assert my_solution.theMaximumAchievableX(**test_input) == 97

test_input = { "num": 1, "t": 49 }
assert my_solution.theMaximumAchievableX(**test_input) == 99

test_input = { "num": 1, "t": 50 }
assert my_solution.theMaximumAchievableX(**test_input) == 101

test_input = { "num": 2, "t": 1 }
assert my_solution.theMaximumAchievableX(**test_input) == 4

test_input = { "num": 2, "t": 2 }
assert my_solution.theMaximumAchievableX(**test_input) == 6

test_input = { "num": 2, "t": 3 }
assert my_solution.theMaximumAchievableX(**test_input) == 8

test_input = { "num": 2, "t": 4 }
assert my_solution.theMaximumAchievableX(**test_input) == 10

test_input = { "num": 2, "t": 5 }
assert my_solution.theMaximumAchievableX(**test_input) == 12

test_input = { "num": 2, "t": 6 }
assert my_solution.theMaximumAchievableX(**test_input) == 14

test_input = { "num": 2, "t": 7 }
assert my_solution.theMaximumAchievableX(**test_input) == 16

test_input = { "num": 2, "t": 8 }
assert my_solution.theMaximumAchievableX(**test_input) == 18

test_input = { "num": 2, "t": 9 }
assert my_solution.theMaximumAchievableX(**test_input) == 20

test_input = { "num": 2, "t": 10 }
assert my_solution.theMaximumAchievableX(**test_input) == 22

test_input = { "num": 2, "t": 11 }
assert my_solution.theMaximumAchievableX(**test_input) == 24

test_input = { "num": 2, "t": 12 }
assert my_solution.theMaximumAchievableX(**test_input) == 26

test_input = { "num": 2, "t": 13 }
assert my_solution.theMaximumAchievableX(**test_input) == 28

test_input = { "num": 2, "t": 14 }
assert my_solution.theMaximumAchievableX(**test_input) == 30

test_input = { "num": 2, "t": 15 }
assert my_solution.theMaximumAchievableX(**test_input) == 32

test_input = { "num": 2, "t": 16 }
assert my_solution.theMaximumAchievableX(**test_input) == 34

test_input = { "num": 2, "t": 17 }
assert my_solution.theMaximumAchievableX(**test_input) == 36

test_input = { "num": 2, "t": 18 }
assert my_solution.theMaximumAchievableX(**test_input) == 38

test_input = { "num": 2, "t": 19 }
assert my_solution.theMaximumAchievableX(**test_input) == 40

test_input = { "num": 2, "t": 20 }
assert my_solution.theMaximumAchievableX(**test_input) == 42

test_input = { "num": 2, "t": 21 }
assert my_solution.theMaximumAchievableX(**test_input) == 44

test_input = { "num": 2, "t": 22 }
assert my_solution.theMaximumAchievableX(**test_input) == 46

test_input = { "num": 2, "t": 23 }
assert my_solution.theMaximumAchievableX(**test_input) == 48

test_input = { "num": 2, "t": 24 }
assert my_solution.theMaximumAchievableX(**test_input) == 50

test_input = { "num": 2, "t": 25 }
assert my_solution.theMaximumAchievableX(**test_input) == 52

test_input = { "num": 2, "t": 26 }
assert my_solution.theMaximumAchievableX(**test_input) == 54

test_input = { "num": 2, "t": 27 }
assert my_solution.theMaximumAchievableX(**test_input) == 56

test_input = { "num": 2, "t": 28 }
assert my_solution.theMaximumAchievableX(**test_input) == 58

test_input = { "num": 2, "t": 29 }
assert my_solution.theMaximumAchievableX(**test_input) == 60

test_input = { "num": 2, "t": 30 }
assert my_solution.theMaximumAchievableX(**test_input) == 62

test_input = { "num": 2, "t": 31 }
assert my_solution.theMaximumAchievableX(**test_input) == 64

test_input = { "num": 2, "t": 32 }
assert my_solution.theMaximumAchievableX(**test_input) == 66

test_input = { "num": 2, "t": 33 }
assert my_solution.theMaximumAchievableX(**test_input) == 68

test_input = { "num": 2, "t": 34 }
assert my_solution.theMaximumAchievableX(**test_input) == 70

test_input = { "num": 2, "t": 35 }
assert my_solution.theMaximumAchievableX(**test_input) == 72

test_input = { "num": 2, "t": 36 }
assert my_solution.theMaximumAchievableX(**test_input) == 74

test_input = { "num": 2, "t": 37 }
assert my_solution.theMaximumAchievableX(**test_input) == 76

test_input = { "num": 2, "t": 38 }
assert my_solution.theMaximumAchievableX(**test_input) == 78

test_input = { "num": 2, "t": 39 }
assert my_solution.theMaximumAchievableX(**test_input) == 80

test_input = { "num": 2, "t": 40 }
assert my_solution.theMaximumAchievableX(**test_input) == 82

test_input = { "num": 2, "t": 41 }
assert my_solution.theMaximumAchievableX(**test_input) == 84

test_input = { "num": 2, "t": 42 }
assert my_solution.theMaximumAchievableX(**test_input) == 86

test_input = { "num": 2, "t": 43 }
assert my_solution.theMaximumAchievableX(**test_input) == 88

test_input = { "num": 2, "t": 44 }
assert my_solution.theMaximumAchievableX(**test_input) == 90

test_input = { "num": 2, "t": 45 }
assert my_solution.theMaximumAchievableX(**test_input) == 92

test_input = { "num": 2, "t": 46 }
assert my_solution.theMaximumAchievableX(**test_input) == 94

test_input = { "num": 2, "t": 47 }
assert my_solution.theMaximumAchievableX(**test_input) == 96

test_input = { "num": 2, "t": 48 }
assert my_solution.theMaximumAchievableX(**test_input) == 98


maximum-number-of-jumps-to-reach-the-last-index

Maximum Number of Jumps to Reach the Last Index

Prompt:
"""
给你一个下标从 0 开始、由 n 个整数组成的数组 nums 和一个整数 target 。

你的初始位置在下标 0 。在一步操作中，你可以从下标 i 跳跃到任意满足下述条件的下标 j ：

 * 0 <= i < j < n
 * -target <= nums[j] - nums[i] <= target

返回到达下标 n - 1 处所需的 最大跳跃次数 。

如果无法到达下标 n - 1 ，返回 -1 。

示例 1：

输入：nums = [1,3,6,4,1,2], target = 2
输出：3
解释：要想以最大跳跃次数从下标 0 到下标 n - 1 ，可以按下述跳跃序列执行操作：
- 从下标 0 跳跃到下标 1 。
- 从下标 1 跳跃到下标 3 。
- 从下标 3 跳跃到下标 5 。
可以证明，从 0 到 n - 1 的所有方案中，不存在比 3 步更长的跳跃序列。因此，答案是 3 。

示例 2：

输入：nums = [1,3,6,4,1,2], target = 3
输出：5
解释：要想以最大跳跃次数从下标 0 到下标 n - 1 ，可以按下述跳跃序列执行操作：
- 从下标 0 跳跃到下标 1 。
- 从下标 1 跳跃到下标 2 。
- 从下标 2 跳跃到下标 3 。
- 从下标 3 跳跃到下标 4 。
- 从下标 4 跳跃到下标 5 。
可以证明，从 0 到 n - 1 的所有方案中，不存在比 5 步更长的跳跃序列。因此，答案是 5 。

示例 3：

输入：nums = [1,3,6,4,1,2], target = 0
输出：-1
解释：可以证明不存在从 0 到 n - 1 的跳跃序列。因此，答案是 -1 。

提示：

 * 2 <= nums.length == n <= 1000
 * -109 <= nums[i] <= 109
 * 0 <= target <= 2 * 109
"""
class Solution:
    def maximumJumps(self, nums: List[int], target: int) -> int:

给你一个下标从 0 开始、由 n 个整数组成的数组 nums 和一个整数 target 。

你的初始位置在下标 0 。在一步操作中，你可以从下标 i 跳跃到任意满足下述条件的下标 j ：

 * 0 <= i < j < n
 * -target <= nums[j] - nums[i] <= target

返回到达下标 n - 1 处所需的 最大跳跃次数 。

如果无法到达下标 n - 1 ，返回 -1 。

示例 1：

输入：nums = [1,3,6,4,1,2], target = 2
输出：3
解释：要想以最大跳跃次数从下标 0 到下标 n - 1 ，可以按下述跳跃序列执行操作：
- 从下标 0 跳跃到下标 1 。
- 从下标 1 跳跃到下标 3 。
- 从下标 3 跳跃到下标 5 。
可以证明，从 0 到 n - 1 的所有方案中，不存在比 3 步更长的跳跃序列。因此，答案是 3 。

示例 2：

输入：nums = [1,3,6,4,1,2], target = 3
输出：5
解释：要想以最大跳跃次数从下标 0 到下标 n - 1 ，可以按下述跳跃序列执行操作：
- 从下标 0 跳跃到下标 1 。
- 从下标 1 跳跃到下标 2 。
- 从下标 2 跳跃到下标 3 。
- 从下标 3 跳跃到下标 4 。
- 从下标 4 跳跃到下标 5 。
可以证明，从 0 到 n - 1 的所有方案中，不存在比 5 步更长的跳跃序列。因此，答案是 5 。

示例 3：

输入：nums = [1,3,6,4,1,2], target = 0
输出：-1
解释：可以证明不存在从 0 到 n - 1 的跳跃序列。因此，答案是 -1 。

提示：

 * 2 <= nums.length == n <= 1000
 * -109 <= nums[i] <= 109
 * 0 <= target <= 2 * 109

请完成下面的代码来解决上述问题:
```python
class Solution:
    def maximumJumps(self, nums: List[int], target: int) -> int:

```

my_solution = Solution()

test_input = { "nums": [1,3,6,4,1,2], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,3,6,4,1,2], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 5

test_input = { "nums": [1,3,6,4,1,2], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,1], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,1], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [0,1], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [1,0], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,0], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [1,0], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [0,1,2], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,1,2], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,1,2], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,1,2], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,2,1], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,2,1], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [0,2,1], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,2,1], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,0,2], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,0,2], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [1,0,2], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,0,2], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,2,0], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,2,0], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [1,2,0], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,2,0], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [2,0,1], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [2,0,1], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [2,0,1], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [2,0,1], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [2,1,0], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [2,1,0], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [2,1,0], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [2,1,0], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,1,2,3], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,1,2,3], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,1,2,3], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,1,2,3], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,1,2,3], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,1,3,2], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,1,3,2], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,1,3,2], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,1,3,2], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,1,3,2], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,2,1,3], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,2,1,3], "target": 1 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,2,1,3], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,2,1,3], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,2,1,3], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,2,3,1], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,2,3,1], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [0,2,3,1], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,2,3,1], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,2,3,1], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,3,1,2], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,3,1,2], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,3,1,2], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,3,1,2], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,3,1,2], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,3,2,1], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [0,3,2,1], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [0,3,2,1], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [0,3,2,1], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [0,3,2,1], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,0,2,3], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,0,2,3], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,0,2,3], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,0,2,3], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,0,2,3], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,0,3,2], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,0,3,2], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [1,0,3,2], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,0,3,2], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,0,3,2], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,2,0,3], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,2,0,3], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,2,0,3], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,2,0,3], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,2,0,3], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,2,3,0], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,2,3,0], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [1,2,3,0], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,2,3,0], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,2,3,0], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,3,0,2], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,3,0,2], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [1,3,0,2], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 2

test_input = { "nums": [1,3,0,2], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,3,0,2], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,3,2,0], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [1,3,2,0], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [1,3,2,0], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,3,2,0], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [1,3,2,0], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [2,0,1,3], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [2,0,1,3], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1

test_input = { "nums": [2,0,1,3], "target": 2 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [2,0,1,3], "target": 3 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [2,0,1,3], "target": 4 }
assert my_solution.maximumJumps(**test_input) == 3

test_input = { "nums": [2,0,3,1], "target": 0 }
assert my_solution.maximumJumps(**test_input) == -1

test_input = { "nums": [2,0,3,1], "target": 1 }
assert my_solution.maximumJumps(**test_input) == 1


longest-non-decreasing-subarray-from-two-arrays

Longest Non-decreasing Subarray From Two Arrays

Prompt:
"""
给你两个下标从 0 开始的整数数组 nums1 和 nums2 ，长度均为 n 。

让我们定义另一个下标从 0 开始、长度为 n 的整数数组，nums3 。对于范围 [0, n - 1] 的每个下标 i ，你可以将 nums1[i] 或 nums2[i] 的值赋给 nums3[i] 。

你的任务是使用最优策略为 nums3 赋值，以最大化 nums3 中 最长非递减子数组 的长度。

以整数形式表示并返回 nums3 中 最长非递减 子数组的长度。

注意：子数组 是数组中的一个连续非空元素序列。

示例 1：

输入：nums1 = [2,3,1], nums2 = [1,2,1]
输出：2
解释：构造 nums3 的方法之一是：
nums3 = [nums1[0], nums2[1], nums2[2]] => [2,2,1]
从下标 0 开始到下标 1 结束，形成了一个长度为 2 的非递减子数组 [2,2] 。
可以证明 2 是可达到的最大长度。

示例 2：

输入：nums1 = [1,3,2,1], nums2 = [2,2,3,4]
输出：4
解释：构造 nums3 的方法之一是：
nums3 = [nums1[0], nums2[1], nums2[2], nums2[3]] => [1,2,3,4]
整个数组形成了一个长度为 4 的非递减子数组，并且是可达到的最大长度。

示例 3：

输入：nums1 = [1,1], nums2 = [2,2]
输出：2
解释：构造 nums3 的方法之一是：
nums3 = [nums1[0], nums1[1]] => [1,1]
整个数组形成了一个长度为 2 的非递减子数组，并且是可达到的最大长度。

提示：

 * 1 <= nums1.length == nums2.length == n <= 105
 * 1 <= nums1[i], nums2[i] <= 109
"""
class Solution:
    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:

给你两个下标从 0 开始的整数数组 nums1 和 nums2 ，长度均为 n 。

让我们定义另一个下标从 0 开始、长度为 n 的整数数组，nums3 。对于范围 [0, n - 1] 的每个下标 i ，你可以将 nums1[i] 或 nums2[i] 的值赋给 nums3[i] 。

你的任务是使用最优策略为 nums3 赋值，以最大化 nums3 中 最长非递减子数组 的长度。

以整数形式表示并返回 nums3 中 最长非递减 子数组的长度。

注意：子数组 是数组中的一个连续非空元素序列。

示例 1：

输入：nums1 = [2,3,1], nums2 = [1,2,1]
输出：2
解释：构造 nums3 的方法之一是：
nums3 = [nums1[0], nums2[1], nums2[2]] => [2,2,1]
从下标 0 开始到下标 1 结束，形成了一个长度为 2 的非递减子数组 [2,2] 。
可以证明 2 是可达到的最大长度。

示例 2：

输入：nums1 = [1,3,2,1], nums2 = [2,2,3,4]
输出：4
解释：构造 nums3 的方法之一是：
nums3 = [nums1[0], nums2[1], nums2[2], nums2[3]] => [1,2,3,4]
整个数组形成了一个长度为 4 的非递减子数组，并且是可达到的最大长度。

示例 3：

输入：nums1 = [1,1], nums2 = [2,2]
输出：2
解释：构造 nums3 的方法之一是：
nums3 = [nums1[0], nums1[1]] => [1,1]
整个数组形成了一个长度为 2 的非递减子数组，并且是可达到的最大长度。

提示：

 * 1 <= nums1.length == nums2.length == n <= 105
 * 1 <= nums1[i], nums2[i] <= 109

请完成下面的代码来解决上述问题:
```python
class Solution:
    def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:

```

my_solution = Solution()

test_input = { "nums1": [2,3,1], "nums2": [1,2,1] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [1,3,2,1], "nums2": [2,2,3,4] }
assert my_solution.maxNonDecreasingLength(**test_input) == 4

test_input = { "nums1": [1,1], "nums2": [2,2] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [1], "nums2": [1] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [1], "nums2": [2] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [1,4], "nums2": [4,19] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [1,8], "nums2": [10,1] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [1,11], "nums2": [9,1] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [1,13], "nums2": [18,1] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [1,19], "nums2": [12,20] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [1,19], "nums2": [18,9] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [2,20], "nums2": [1,18] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [3,5], "nums2": [13,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [3,6], "nums2": [10,12] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [3,7], "nums2": [8,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [3,8], "nums2": [15,2] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [3,9], "nums2": [11,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [3,12], "nums2": [7,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [3,12], "nums2": [20,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [3,20], "nums2": [5,17] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [4,2], "nums2": [10,4] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [4,12], "nums2": [6,4] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [4,15], "nums2": [3,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [5,5], "nums2": [19,8] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [5,7], "nums2": [19,5] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [5,11], "nums2": [2,5] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [5,14], "nums2": [8,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [5,15], "nums2": [16,5] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [5,20], "nums2": [4,5] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [5,20], "nums2": [10,17] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [6,7], "nums2": [3,2] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [6,14], "nums2": [5,5] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [6,14], "nums2": [18,6] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [6,16], "nums2": [16,20] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [6,17], "nums2": [4,20] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [7,3], "nums2": [16,7] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [7,4], "nums2": [15,7] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [7,9], "nums2": [3,18] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [7,10], "nums2": [10,14] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [7,11], "nums2": [5,7] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [7,12], "nums2": [20,5] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [7,20], "nums2": [12,8] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [8,5], "nums2": [13,8] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [8,11], "nums2": [9,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [8,16], "nums2": [9,8] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [8,17], "nums2": [2,8] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [8,18], "nums2": [16,12] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [4,2], "nums2": [10,4] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [9,1], "nums2": [11,9] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [9,6], "nums2": [8,14] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [9,9], "nums2": [11,8] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [9,12], "nums2": [20,9] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [9,15], "nums2": [20,9] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [9,16], "nums2": [11,15] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [9,19], "nums2": [17,9] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [10,19], "nums2": [17,10] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [11,1], "nums2": [3,11] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [11,3], "nums2": [9,17] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [11,6], "nums2": [9,17] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [11,19], "nums2": [17,11] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [11,69], "nums2": [26,62] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [12,1], "nums2": [10,12] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [12,10], "nums2": [16,2] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [13,6], "nums2": [20,13] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [13,16], "nums2": [5,13] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [14,2], "nums2": [2,14] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [14,4], "nums2": [2,13] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [15,10], "nums2": [17,15] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [15,11], "nums2": [19,2] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [16,9], "nums2": [5,16] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [16,17], "nums2": [9,16] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [17,8], "nums2": [11,10] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [17,10], "nums2": [9,17] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [17,10], "nums2": [18,7] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [17,11], "nums2": [19,17] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [17,14], "nums2": [17,17] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [17,17], "nums2": [15,17] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [17,17], "nums2": [16,1] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [18,4], "nums2": [1,6] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [18,9], "nums2": [10,18] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [18,9], "nums2": [17,18] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [18,10], "nums2": [1,18] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [18,104], "nums2": [117,18] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [19,2], "nums2": [1,19] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [19,5], "nums2": [15,5] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [19,5], "nums2": [52,10] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [19,15], "nums2": [12,19] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [19,15], "nums2": [18,4] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [20,1], "nums2": [1,20] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [20,5], "nums2": [2,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [20,5], "nums2": [14,8] }
assert my_solution.maxNonDecreasingLength(**test_input) == 1

test_input = { "nums1": [20,7], "nums2": [12,20] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [20,12], "nums2": [2,20] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [20,16], "nums2": [8,5] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [20,18], "nums2": [18,20] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [25,83], "nums2": [28,18] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [26,47], "nums2": [87,26] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [28,41], "nums2": [87,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [36,53], "nums2": [66,3] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2

test_input = { "nums1": [44,34], "nums2": [53,44] }
assert my_solution.maxNonDecreasingLength(**test_input) == 2


apply-operations-to-make-all-array-elements-equal-to-zero

Apply Operations to Make All Array Elements Equal to Zero

Prompt:
"""
给你一个下标从 0 开始的整数数组 nums 和一个正整数 k 。

你可以对数组执行下述操作 任意次 ：

 * 从数组中选出长度为 k 的 任一 子数组，并将子数组中每个元素都 减去 1 。

如果你可以使数组中的所有元素都等于 0 ，返回  true ；否则，返回 false 。

子数组 是数组中的一个非空连续元素序列。

示例 1：

输入：nums = [2,2,3,1,1,0], k = 3
输出：true
解释：可以执行下述操作：
- 选出子数组 [2,2,3] ，执行操作后，数组变为 nums = [1,1,2,1,1,0] 。
- 选出子数组 [2,1,1] ，执行操作后，数组变为 nums = [1,1,1,0,0,0] 。
- 选出子数组 [1,1,1] ，执行操作后，数组变为 nums = [0,0,0,0,0,0] 。

示例 2：

输入：nums = [1,3,1,1], k = 2
输出：false
解释：无法使数组中的所有元素等于 0 。

提示：

 * 1 <= k <= nums.length <= 105
 * 0 <= nums[i] <= 106
"""
class Solution:
    def checkArray(self, nums: List[int], k: int) -> bool:

给你一个下标从 0 开始的整数数组 nums 和一个正整数 k 。

你可以对数组执行下述操作 任意次 ：

 * 从数组中选出长度为 k 的 任一 子数组，并将子数组中每个元素都 减去 1 。

如果你可以使数组中的所有元素都等于 0 ，返回  true ；否则，返回 false 。

子数组 是数组中的一个非空连续元素序列。

示例 1：

输入：nums = [2,2,3,1,1,0], k = 3
输出：true
解释：可以执行下述操作：
- 选出子数组 [2,2,3] ，执行操作后，数组变为 nums = [1,1,2,1,1,0] 。
- 选出子数组 [2,1,1] ，执行操作后，数组变为 nums = [1,1,1,0,0,0] 。
- 选出子数组 [1,1,1] ，执行操作后，数组变为 nums = [0,0,0,0,0,0] 。

示例 2：

输入：nums = [1,3,1,1], k = 2
输出：false
解释：无法使数组中的所有元素等于 0 。

提示：

 * 1 <= k <= nums.length <= 105
 * 0 <= nums[i] <= 106

请完成下面的代码来解决上述问题:
```python
class Solution:
    def checkArray(self, nums: List[int], k: int) -> bool:

```


longest-alternating-subarray

Longest Alternating Subarray

Prompt:
"""
给你一个下标从 0 开始的整数数组 nums 。如果 nums 中长度为 m 的子数组 s 满足以下条件，我们称它是一个 交替子序列 ：

 * m 大于 1 。
 * s1 = s0 + 1 。
 * 下标从 0 开始的子数组 s 与数组 [s0, s1, s0, s1,...,s(m-1) % 2] 一样。也就是说，s1 - s0 = 1 ，s2 - s1 = -1 ，s3 - s2 = 1 ，s4 - s3 = -1 ，以此类推，直到 s[m - 1] - s[m - 2] = (-1)m 。

请你返回 nums 中所有 交替 子数组中，最长的长度，如果不存在交替子数组，请你返回 -1 。

子数组是一个数组中一段连续 非空 的元素序列。

示例 1：

输入：nums = [2,3,4,3,4]
输出：4
解释：交替子数组有 [3,4] ，[3,4,3] 和 [3,4,3,4] 。最长的子数组为 [3,4,3,4] ，长度为4 。

示例 2：

输入：nums = [4,5,6]
输出：2
解释：[4,5] 和 [5,6] 是仅有的两个交替子数组。它们长度都为 2 。

提示：

 * 2 <= nums.length <= 100
 * 1 <= nums[i] <= 104
"""
class Solution:
    def alternatingSubarray(self, nums: List[int]) -> int:

给你一个下标从 0 开始的整数数组 nums 。如果 nums 中长度为 m 的子数组 s 满足以下条件，我们称它是一个 交替子序列 ：

 * m 大于 1 。
 * s1 = s0 + 1 。
 * 下标从 0 开始的子数组 s 与数组 [s0, s1, s0, s1,...,s(m-1) % 2] 一样。也就是说，s1 - s0 = 1 ，s2 - s1 = -1 ，s3 - s2 = 1 ，s4 - s3 = -1 ，以此类推，直到 s[m - 1] - s[m - 2] = (-1)m 。

请你返回 nums 中所有 交替 子数组中，最长的长度，如果不存在交替子数组，请你返回 -1 。

子数组是一个数组中一段连续 非空 的元素序列。

示例 1：

输入：nums = [2,3,4,3,4]
输出：4
解释：交替子数组有 [3,4] ，[3,4,3] 和 [3,4,3,4] 。最长的子数组为 [3,4,3,4] ，长度为4 。

示例 2：

输入：nums = [4,5,6]
输出：2
解释：[4,5] 和 [5,6] 是仅有的两个交替子数组。它们长度都为 2 。

提示：

 * 2 <= nums.length <= 100
 * 1 <= nums[i] <= 104

请完成下面的代码来解决上述问题:
```python
class Solution:
    def alternatingSubarray(self, nums: List[int]) -> int:

```

my_solution = Solution()

test_input = { "nums": [2,3,4,3,4] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [4,5,6] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [31,32,31,32,33] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [21,9,5] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [42,43,44,43,44,43,44,45,46] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [13,14,15,14] }
assert my_solution.alternatingSubarray(**test_input) == 3

test_input = { "nums": [74,75,74,75,74,75,74,75] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [77,78,79,78,79,78,79,78,79,80] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [88,42,53] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [64,65,64,65,64,65,66,65,66,65] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [99,100,99,100] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [21,22] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [23,24,23,24,25,24,25,24,25] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [20,9,15,15] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [92,93,92,93,92] }
assert my_solution.alternatingSubarray(**test_input) == 5

test_input = { "nums": [24,25,26] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [51,52,53,52,53,52,53,54,53] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [65,66,65,66,67,68,69] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [29,2,5,24] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [26,27,26,27,28,27,28,27,28] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [21,22,21,22,21,22] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [94,95,94,95,94] }
assert my_solution.alternatingSubarray(**test_input) == 5

test_input = { "nums": [82,83,84,83,84,83,84,83] }
assert my_solution.alternatingSubarray(**test_input) == 7

test_input = { "nums": [14,30,29,49,3,23,44,21,26,52] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [4,5,4,5,6,5,6] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [62,63] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [24,25,26,25,26,25,26,25,26] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [55,56,55,56,55,56,55,56,57,56] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [52,77,42,21] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [80,81] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [50,51,50,51,50,51,50,51,50] }
assert my_solution.alternatingSubarray(**test_input) == 9

test_input = { "nums": [83,84,83] }
assert my_solution.alternatingSubarray(**test_input) == 3

test_input = { "nums": [17,18,17,18,19,18,19,20,19,20] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [5,14,8,12,5,4] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [35,36,35,36,35,36,35,36,35,36] }
assert my_solution.alternatingSubarray(**test_input) == 10

test_input = { "nums": [8,9,8,9,8,9] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [59,60] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [55,56,55] }
assert my_solution.alternatingSubarray(**test_input) == 3

test_input = { "nums": [47,46,65,37,24,54,39,70] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [45,46,45,46,45,46,45] }
assert my_solution.alternatingSubarray(**test_input) == 7

test_input = { "nums": [78,79,78,79,78,79,78,79,80,79] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [65,66,65,66,65,66,67,68] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [62,63,62,63,62,63] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [7,10,5,2,11,3,9,12,9,11] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [79,80,79,80,79,80] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [19,20,21,20,21,22] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [84,85,86,85,86,85,86,87,88,87] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [54,55] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [71,14,24,13,21,14,18,84,37,2] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [26,27,26] }
assert my_solution.alternatingSubarray(**test_input) == 3

test_input = { "nums": [53,54,53,54,53] }
assert my_solution.alternatingSubarray(**test_input) == 5

test_input = { "nums": [67,68,67,68,67,68,69,70,69,70] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [85,86,85,86,85,86,85,86,85,86] }
assert my_solution.alternatingSubarray(**test_input) == 10

test_input = { "nums": [22,16,27,22,44,10] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [27,28,27,28,27,28,27,28,29,28] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [54,55,54,55,54,55,54,55,56,57] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [24,25,26,27,28] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [55,56] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [13,6,6,8,12,7,1] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [40,41,40,41,40,41,40,41] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [10,11,10,11,10,11,12] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [58,59,58,59] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [1,15,44,74,56,41,48,71] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [89,90,89,90,89,90] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [4,5,4,5,4,5,6] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [50,51,52,53,52,53] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [44,45,46,45,46,45,46,47,48] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [16,3,25,12,2,19,1,26] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [17,18,19,20,19,20] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [91,92,93,92,93] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [28,29,28,29,28,29,30] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [88,89,88,89,88,89] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [1,1,1,1,1,1,1,1,1,1] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [32,33,32,33,32,33,34] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [61,62,61,62,63,62,63,64,63] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [6,7,6,7] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [20,21,20,21,20] }
assert my_solution.alternatingSubarray(**test_input) == 5

test_input = { "nums": [14,6,21] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [12,13,12,13,12,13,12,13,12] }
assert my_solution.alternatingSubarray(**test_input) == 9

test_input = { "nums": [33,34,33,34,33,34,33] }
assert my_solution.alternatingSubarray(**test_input) == 7

test_input = { "nums": [92,93,92] }
assert my_solution.alternatingSubarray(**test_input) == 3

test_input = { "nums": [93,94,95,94,95,96,95,96,97] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [8,4,27] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [30,31,32,31,32,33,34,33] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [26,27,26,27,26,27] }
assert my_solution.alternatingSubarray(**test_input) == 6

test_input = { "nums": [67,68,69] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [83,84,85,84,85] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [6,26,4,2] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [81,82,81,82,81,82,81,82,83] }
assert my_solution.alternatingSubarray(**test_input) == 8

test_input = { "nums": [58,59] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [82,83,82,83,82,83,82,83,82] }
assert my_solution.alternatingSubarray(**test_input) == 9

test_input = { "nums": [48,49] }
assert my_solution.alternatingSubarray(**test_input) == 2

test_input = { "nums": [8,6,2] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [69,70,69,70,69,70,69,70,69] }
assert my_solution.alternatingSubarray(**test_input) == 9

test_input = { "nums": [28,29,28,29] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [82,83,82,83,84] }
assert my_solution.alternatingSubarray(**test_input) == 4

test_input = { "nums": [97,98,97,98,97,98,97] }
assert my_solution.alternatingSubarray(**test_input) == 7

test_input = { "nums": [2,2,1] }
assert my_solution.alternatingSubarray(**test_input) == -1

test_input = { "nums": [84,85,84,85,84,85,84] }
assert my_solution.alternatingSubarray(**test_input) == 7

test_input = { "nums": [21,22,21,22] }
assert my_solution.alternatingSubarray(**test_input) == 4


relocate-marbles

Relocate Marbles

Prompt:
"""
给你一个下标从 0 开始的整数数组 nums ，表示一些石块的初始位置。再给你两个长度 相等 下标从 0 开始的整数数组 moveFrom 和 moveTo 。

在 moveFrom.length 次操作内，你可以改变石块的位置。在第 i 次操作中，你将位置在 moveFrom[i] 的所有石块移到位置 moveTo[i] 。

完成这些操作后，请你按升序返回所有 有 石块的位置。

注意：

 * 如果一个位置至少有一个石块，我们称这个位置 有 石块。
 * 一个位置可能会有多个石块。

示例 1：

输入：nums = [1,6,7,8], moveFrom = [1,7,2], moveTo = [2,9,5]
输出：[5,6,8,9]
解释：一开始，石块在位置 1,6,7,8 。
第 i = 0 步操作中，我们将位置 1 处的石块移到位置 2 处，位置 2,6,7,8 有石块。
第 i = 1 步操作中，我们将位置 7 处的石块移到位置 9 处，位置 2,6,8,9 有石块。
第 i = 2 步操作中，我们将位置 2 处的石块移到位置 5 处，位置 5,6,8,9 有石块。
最后，至少有一个石块的位置为 [5,6,8,9] 。

示例 2：

输入：nums = [1,1,3,3], moveFrom = [1,3], moveTo = [2,2]
输出：[2]
解释：一开始，石块在位置 [1,1,3,3] 。
第 i = 0 步操作中，我们将位置 1 处的石块移到位置 2 处，有石块的位置为 [2,2,3,3] 。
第 i = 1 步操作中，我们将位置 3 处的石块移到位置 2 处，有石块的位置为 [2,2,2,2] 。
由于 2 是唯一有石块的位置，我们返回 [2] 。

提示：

 * 1 <= nums.length <= 105
 * 1 <= moveFrom.length <= 105
 * moveFrom.length == moveTo.length
 * 1 <= nums[i], moveFrom[i], moveTo[i] <= 109
 * 测试数据保证在进行第 i 步操作时，moveFrom[i] 处至少有一个石块。
"""
class Solution:
    def relocateMarbles(self, nums: List[int], moveFrom: List[int], moveTo: List[int]) -> List[int]:

给你一个下标从 0 开始的整数数组 nums ，表示一些石块的初始位置。再给你两个长度 相等 下标从 0 开始的整数数组 moveFrom 和 moveTo 。

在 moveFrom.length 次操作内，你可以改变石块的位置。在第 i 次操作中，你将位置在 moveFrom[i] 的所有石块移到位置 moveTo[i] 。

完成这些操作后，请你按升序返回所有 有 石块的位置。

注意：

 * 如果一个位置至少有一个石块，我们称这个位置 有 石块。
 * 一个位置可能会有多个石块。

示例 1：

输入：nums = [1,6,7,8], moveFrom = [1,7,2], moveTo = [2,9,5]
输出：[5,6,8,9]
解释：一开始，石块在位置 1,6,7,8 。
第 i = 0 步操作中，我们将位置 1 处的石块移到位置 2 处，位置 2,6,7,8 有石块。
第 i = 1 步操作中，我们将位置 7 处的石块移到位置 9 处，位置 2,6,8,9 有石块。
第 i = 2 步操作中，我们将位置 2 处的石块移到位置 5 处，位置 5,6,8,9 有石块。
最后，至少有一个石块的位置为 [5,6,8,9] 。

示例 2：

输入：nums = [1,1,3,3], moveFrom = [1,3], moveTo = [2,2]
输出：[2]
解释：一开始，石块在位置 [1,1,3,3] 。
第 i = 0 步操作中，我们将位置 1 处的石块移到位置 2 处，有石块的位置为 [2,2,3,3] 。
第 i = 1 步操作中，我们将位置 3 处的石块移到位置 2 处，有石块的位置为 [2,2,2,2] 。
由于 2 是唯一有石块的位置，我们返回 [2] 。

提示：

 * 1 <= nums.length <= 105
 * 1 <= moveFrom.length <= 105
 * moveFrom.length == moveTo.length
 * 1 <= nums[i], moveFrom[i], moveTo[i] <= 109
 * 测试数据保证在进行第 i 步操作时，moveFrom[i] 处至少有一个石块。

请完成下面的代码来解决上述问题:
```python
class Solution:
    def relocateMarbles(self, nums: List[int], moveFrom: List[int], moveTo: List[int]) -> List[int]:

```


partition-string-into-minimum-beautiful-substrings

Partition String Into Minimum Beautiful Substrings

Prompt:
"""
给你一个二进制字符串 s ，你需要将字符串分割成一个或者多个 子字符串  ，使每个子字符串都是 美丽 的。

如果一个字符串满足以下条件，我们称它是 美丽 的：

 * 它不包含前导 0 。
 * 它是 5 的幂的 二进制 表示。

请你返回分割后的子字符串的 最少 数目。如果无法将字符串 s 分割成美丽子字符串，请你返回 -1 。

子字符串是一个字符串中一段连续的字符序列。

示例 1：

输入：s = "1011"
输出：2
解释：我们可以将输入字符串分成 ["101", "1"] 。
- 字符串 "101" 不包含前导 0 ，且它是整数 51 = 5 的二进制表示。
- 字符串 "1" 不包含前导 0 ，且它是整数 50 = 1 的二进制表示。
最少可以将 s 分成 2 个美丽子字符串。

示例 2：

输入：s = "111"
输出：3
解释：我们可以将输入字符串分成 ["1", "1", "1"] 。
- 字符串 "1" 不包含前导 0 ，且它是整数 50 = 1 的二进制表示。
最少可以将 s 分成 3 个美丽子字符串。

示例 3：

输入：s = "0"
输出：-1
解释：无法将给定字符串分成任何美丽子字符串。

提示：

 * 1 <= s.length <= 15
 * s[i] 要么是 '0' 要么是 '1' 。
"""
class Solution:
    def minimumBeautifulSubstrings(self, s: str) -> int:

给你一个二进制字符串 s ，你需要将字符串分割成一个或者多个 子字符串  ，使每个子字符串都是 美丽 的。

如果一个字符串满足以下条件，我们称它是 美丽 的：

 * 它不包含前导 0 。
 * 它是 5 的幂的 二进制 表示。

请你返回分割后的子字符串的 最少 数目。如果无法将字符串 s 分割成美丽子字符串，请你返回 -1 。

子字符串是一个字符串中一段连续的字符序列。

示例 1：

输入：s = "1011"
输出：2
解释：我们可以将输入字符串分成 ["101", "1"] 。
- 字符串 "101" 不包含前导 0 ，且它是整数 51 = 5 的二进制表示。
- 字符串 "1" 不包含前导 0 ，且它是整数 50 = 1 的二进制表示。
最少可以将 s 分成 2 个美丽子字符串。

示例 2：

输入：s = "111"
输出：3
解释：我们可以将输入字符串分成 ["1", "1", "1"] 。
- 字符串 "1" 不包含前导 0 ，且它是整数 50 = 1 的二进制表示。
最少可以将 s 分成 3 个美丽子字符串。

示例 3：

输入：s = "0"
输出：-1
解释：无法将给定字符串分成任何美丽子字符串。

提示：

 * 1 <= s.length <= 15
 * s[i] 要么是 '0' 要么是 '1' 。

请完成下面的代码来解决上述问题:
```python
class Solution:
    def minimumBeautifulSubstrings(self, s: str) -> int:

```

my_solution = Solution()

test_input = { "s": "1011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 2

test_input = { "s": "111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "0" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == -1

test_input = { "s": "100111000110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "100111000111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "1001110001111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "100111000111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10110011100011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 2

test_input = { "s": "101101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "101101101101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "1011011011101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10110110111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101101101111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "1011011011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101101110011101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10110111001111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011011101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101101110110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101101110111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011011101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101101110111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10110111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101101111001101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10110111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10110111101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101101111011011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101101111011101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10110111101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101101111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "1011011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011011111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101101111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011011111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10110111110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "10110111111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101101111110011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10110111111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "101101111110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101101111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101101111111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101110011011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10111001101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "101110011011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011100111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10111001110001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "10111001110011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "1011100111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111001110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "10111001111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111001111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "1011100111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101110011110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101110011111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111001111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101110011111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011100111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111001111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "1011101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10111011011011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101110110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101110110111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011101101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101110111001101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101110111001111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111011101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111011101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101110111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "1011101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011101111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111011110011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101110111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011101111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111011111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "10111011111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101110111110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "101110111111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101110111111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101110111111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111011111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 10

test_input = { "s": "101110111111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 11

test_input = { "s": "101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "101111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "1011110011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10111100110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101111001110001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "101111001111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111100111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101111011011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "10111101101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011110110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011110111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101111011110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "101111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "1011110111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "101111011111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111101111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 10