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

Maximum Beauty of an Array After Applying Operation

Prompt:
"""
You are given a 0-indexed array nums and a non-negative integer k.

In one operation, you can do the following:

 * Choose an index i that hasn't been chosen before from the range [0, nums.length - 1].
 * Replace nums[i] with any integer from the range [nums[i] - k, nums[i] + k].

The beauty of the array is the length of the longest subsequence consisting of equal elements.

Return the maximum possible beauty of the array nums after applying the operation any number of times.

Note that you can apply the operation to each index only once.

A subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the order of the remaining elements.

Example 1:

Input: nums = [4,6,1,2], k = 2
Output: 3
Explanation: In this example, we apply the following operations:
- Choose index 1, replace it with 4 (from range [4,8]), nums = [4,4,1,2].
- Choose index 3, replace it with 4 (from range [0,4]), nums = [4,4,1,4].
After the applied operations, the beauty of the array nums is 3 (subsequence consisting of indices 0, 1, and 3).
It can be proven that 3 is the maximum possible length we can achieve.

Example 2:

Input: nums = [1,1,1,1], k = 10
Output: 4
Explanation: In this example we don't have to apply any operations.
The beauty of the array nums is 4 (whole array).

Constraints:

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

You are given a 0-indexed array nums and a non-negative integer k.

In one operation, you can do the following:

 * Choose an index i that hasn't been chosen before from the range [0, nums.length - 1].
 * Replace nums[i] with any integer from the range [nums[i] - k, nums[i] + k].

The beauty of the array is the length of the longest subsequence consisting of equal elements.

Return the maximum possible beauty of the array nums after applying the operation any number of times.

Note that you can apply the operation to each index only once.

A subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the order of the remaining elements.

Example 1:

Input: nums = [4,6,1,2], k = 2
Output: 3
Explanation: In this example, we apply the following operations:
- Choose index 1, replace it with 4 (from range [4,8]), nums = [4,4,1,2].
- Choose index 3, replace it with 4 (from range [0,4]), nums = [4,4,1,4].
After the applied operations, the beauty of the array nums is 3 (subsequence consisting of indices 0, 1, and 3).
It can be proven that 3 is the maximum possible length we can achieve.

Example 2:

Input: nums = [1,1,1,1], k = 10
Output: 4
Explanation: In this example we don't have to apply any operations.
The beauty of the array nums is 4 (whole array).

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
An element x of an integer array arr of length m is dominant if freq(x) * 2 > m, where freq(x) is the number of occurrences of x in arr. Note that this definition implies that arr can have at most one dominant element.

You are given a 0-indexed integer array nums of length n with one dominant element.

You can split nums at an index i into two arrays nums[0, ..., i] and nums[i + 1, ..., n - 1], but the split is only valid if:

 * 0 <= i < n - 1
 * nums[0, ..., i], and nums[i + 1, ..., n - 1] have the same dominant element.

Here, nums[i, ..., j] denotes the subarray of nums starting at index i and ending at index j, both ends being inclusive. Particularly, if j < i then nums[i, ..., j] denotes an empty subarray.

Return the minimum index of a valid split. If no valid split exists, return -1.

Example 1:

Input: nums = [1,2,2,2]
Output: 2
Explanation: We can split the array at index 2 to obtain arrays [1,2,2] and [2].
In array [1,2,2], element 2 is dominant since it occurs twice in the array and 2 * 2 > 3.
In array [2], element 2 is dominant since it occurs once in the array and 1 * 2 > 1.
Both [1,2,2] and [2] have the same dominant element as nums, so this is a valid split.
It can be shown that index 2 is the minimum index of a valid split.

Example 2:

Input: nums = [2,1,3,1,1,1,7,1,2,1]
Output: 4
Explanation: We can split the array at index 4 to obtain arrays [2,1,3,1,1] and [1,7,1,2,1].
In array [2,1,3,1,1], element 1 is dominant since it occurs thrice in the array and 3 * 2 > 5.
In array [1,7,1,2,1], element 1 is dominant since it occurs thrice in the array and 3 * 2 > 5.
Both [2,1,3,1,1] and [1,7,1,2,1] have the same dominant element as nums, so this is a valid split.
It can be shown that index 4 is the minimum index of a valid split.

Example 3:

Input: nums = [3,3,3,3,7,2,2]
Output: -1
Explanation: It can be shown that there is no valid split.

Constraints:

 * 1 <= nums.length <= 105
 * 1 <= nums[i] <= 109
 * nums has exactly one dominant element.
"""
class Solution:
    def minimumIndex(self, nums: List[int]) -> int:

An element x of an integer array arr of length m is dominant if freq(x) * 2 > m, where freq(x) is the number of occurrences of x in arr. Note that this definition implies that arr can have at most one dominant element.

You are given a 0-indexed integer array nums of length n with one dominant element.

You can split nums at an index i into two arrays nums[0, ..., i] and nums[i + 1, ..., n - 1], but the split is only valid if:

 * 0 <= i < n - 1
 * nums[0, ..., i], and nums[i + 1, ..., n - 1] have the same dominant element.

Here, nums[i, ..., j] denotes the subarray of nums starting at index i and ending at index j, both ends being inclusive. Particularly, if j < i then nums[i, ..., j] denotes an empty subarray.

Return the minimum index of a valid split. If no valid split exists, return -1.

Example 1:

Input: nums = [1,2,2,2]
Output: 2
Explanation: We can split the array at index 2 to obtain arrays [1,2,2] and [2].
In array [1,2,2], element 2 is dominant since it occurs twice in the array and 2 * 2 > 3.
In array [2], element 2 is dominant since it occurs once in the array and 1 * 2 > 1.
Both [1,2,2] and [2] have the same dominant element as nums, so this is a valid split.
It can be shown that index 2 is the minimum index of a valid split.

Example 2:

Input: nums = [2,1,3,1,1,1,7,1,2,1]
Output: 4
Explanation: We can split the array at index 4 to obtain arrays [2,1,3,1,1] and [1,7,1,2,1].
In array [2,1,3,1,1], element 1 is dominant since it occurs thrice in the array and 3 * 2 > 5.
In array [1,7,1,2,1], element 1 is dominant since it occurs thrice in the array and 3 * 2 > 5.
Both [2,1,3,1,1] and [1,7,1,2,1] have the same dominant element as nums, so this is a valid split.
It can be shown that index 4 is the minimum index of a valid split.

Example 3:

Input: nums = [3,3,3,3,7,2,2]
Output: -1
Explanation: It can be shown that there is no valid split.

Constraints:

 * 1 <= nums.length <= 105
 * 1 <= nums[i] <= 109
 * nums has exactly one dominant element.

Please complete the code below to solve above prblem:
```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:
"""
You are given a string word and an array of strings forbidden.

A string is called valid if none of its substrings are present in forbidden.

Return the length of the longest valid substring of the string word.

A substring is a contiguous sequence of characters in a string, possibly empty.

Example 1:

Input: word = "cbaaaabc", forbidden = ["aaa","cb"]
Output: 4
Explanation: There are 11 valid substrings in word: "c", "b", "a", "ba", "aa", "bc", "baa", "aab", "ab", "abc" and "aabc". The length of the longest valid substring is 4.
It can be shown that all other substrings contain either "aaa" or "cb" as a substring.

Example 2:

Input: word = "leetcode", forbidden = ["de","le","e"]
Output: 4
Explanation: There are 11 valid substrings in word: "l", "t", "c", "o", "d", "tc", "co", "od", "tco", "cod", and "tcod". The length of the longest valid substring is 4.
It can be shown that all other substrings contain either "de", "le", or "e" as a substring.

Constraints:

 * 1 <= word.length <= 105
 * word consists only of lowercase English letters.
 * 1 <= forbidden.length <= 105
 * 1 <= forbidden[i].length <= 10
 * forbidden[i] consists only of lowercase English letters.
"""
class Solution:
    def longestValidSubstring(self, word: str, forbidden: List[str]) -> int:

You are given a string word and an array of strings forbidden.

A string is called valid if none of its substrings are present in forbidden.

Return the length of the longest valid substring of the string word.

A substring is a contiguous sequence of characters in a string, possibly empty.

Example 1:

Input: word = "cbaaaabc", forbidden = ["aaa","cb"]
Output: 4
Explanation: There are 11 valid substrings in word: "c", "b", "a", "ba", "aa", "bc", "baa", "aab", "ab", "abc" and "aabc". The length of the longest valid substring is 4.
It can be shown that all other substrings contain either "aaa" or "cb" as a substring.

Example 2:

Input: word = "leetcode", forbidden = ["de","le","e"]
Output: 4
Explanation: There are 11 valid substrings in word: "l", "t", "c", "o", "d", "tc", "co", "od", "tco", "cod", and "tcod". The length of the longest valid substring is 4.
It can be shown that all other substrings contain either "de", "le", or "e" as a substring.

Constraints:

 * 1 <= word.length <= 105
 * word consists only of lowercase English letters.
 * 1 <= forbidden.length <= 105
 * 1 <= forbidden[i].length <= 10
 * forbidden[i] consists only of lowercase English letters.

Please complete the code below to solve above prblem:
```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:
"""
You are given two integers, num and t.

An integer x is called achievable if it can become equal to num after applying the following operation no more than t times:

 * Increase or decrease x by 1, and simultaneously increase or decrease num by 1.

Return the maximum possible achievable number. It can be proven that there exists at least one achievable number.

Example 1:

Input: num = 4, t = 1
Output: 6
Explanation: The maximum achievable number is x = 6; it can become equal to num after performing this operation:
1- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
It can be proven that there is no achievable number larger than 6.

Example 2:

Input: num = 3, t = 2
Output: 7
Explanation: The maximum achievable number is x = 7; after performing these operations, x will equal num:
1- Decrease x by 1, and increase num by 1. Now, x = 6 and num = 4.
2- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
It can be proven that there is no achievable number larger than 7.

Constraints:

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

You are given two integers, num and t.

An integer x is called achievable if it can become equal to num after applying the following operation no more than t times:

 * Increase or decrease x by 1, and simultaneously increase or decrease num by 1.

Return the maximum possible achievable number. It can be proven that there exists at least one achievable number.

Example 1:

Input: num = 4, t = 1
Output: 6
Explanation: The maximum achievable number is x = 6; it can become equal to num after performing this operation:
1- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
It can be proven that there is no achievable number larger than 6.

Example 2:

Input: num = 3, t = 2
Output: 7
Explanation: The maximum achievable number is x = 7; after performing these operations, x will equal num:
1- Decrease x by 1, and increase num by 1. Now, x = 6 and num = 4.
2- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
It can be proven that there is no achievable number larger than 7.

Constraints:

 * 1 <= num, t <= 50

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed array nums of n integers and an integer target.

You are initially positioned at index 0. In one step, you can jump from index i to any index j such that:

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

Return the maximum number of jumps you can make to reach index n - 1.

If there is no way to reach index n - 1, return -1.

Example 1:

Input: nums = [1,3,6,4,1,2], target = 2
Output: 3
Explanation: To go from index 0 to index n - 1 with the maximum number of jumps, you can perform the following jumping sequence:
- Jump from index 0 to index 1.
- Jump from index 1 to index 3.
- Jump from index 3 to index 5.
It can be proven that there is no other jumping sequence that goes from 0 to n - 1 with more than 3 jumps. Hence, the answer is 3.

Example 2:

Input: nums = [1,3,6,4,1,2], target = 3
Output: 5
Explanation: To go from index 0 to index n - 1 with the maximum number of jumps, you can perform the following jumping sequence:
- Jump from index 0 to index 1.
- Jump from index 1 to index 2.
- Jump from index 2 to index 3.
- Jump from index 3 to index 4.
- Jump from index 4 to index 5.
It can be proven that there is no other jumping sequence that goes from 0 to n - 1 with more than 5 jumps. Hence, the answer is 5.

Example 3:

Input: nums = [1,3,6,4,1,2], target = 0
Output: -1
Explanation: It can be proven that there is no jumping sequence that goes from 0 to n - 1. Hence, the answer is -1.

Constraints:

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

You are given a 0-indexed array nums of n integers and an integer target.

You are initially positioned at index 0. In one step, you can jump from index i to any index j such that:

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

Return the maximum number of jumps you can make to reach index n - 1.

If there is no way to reach index n - 1, return -1.

Example 1:

Input: nums = [1,3,6,4,1,2], target = 2
Output: 3
Explanation: To go from index 0 to index n - 1 with the maximum number of jumps, you can perform the following jumping sequence:
- Jump from index 0 to index 1.
- Jump from index 1 to index 3.
- Jump from index 3 to index 5.
It can be proven that there is no other jumping sequence that goes from 0 to n - 1 with more than 3 jumps. Hence, the answer is 3.

Example 2:

Input: nums = [1,3,6,4,1,2], target = 3
Output: 5
Explanation: To go from index 0 to index n - 1 with the maximum number of jumps, you can perform the following jumping sequence:
- Jump from index 0 to index 1.
- Jump from index 1 to index 2.
- Jump from index 2 to index 3.
- Jump from index 3 to index 4.
- Jump from index 4 to index 5.
It can be proven that there is no other jumping sequence that goes from 0 to n - 1 with more than 5 jumps. Hence, the answer is 5.

Example 3:

Input: nums = [1,3,6,4,1,2], target = 0
Output: -1
Explanation: It can be proven that there is no jumping sequence that goes from 0 to n - 1. Hence, the answer is -1.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given two 0-indexed integer arrays nums1 and nums2 of length n.

Let's define another 0-indexed integer array, nums3, of length n. For each index i in the range [0, n - 1], you can assign either nums1[i] or nums2[i] to nums3[i].

Your task is to maximize the length of the longest non-decreasing subarray in nums3 by choosing its values optimally.

Return an integer representing the length of the longest non-decreasing subarray in nums3.

Note: A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums1 = [2,3,1], nums2 = [1,2,1]
Output: 2
Explanation: One way to construct nums3 is:
nums3 = [nums1[0], nums2[1], nums2[2]] => [2,2,1].
The subarray starting from index 0 and ending at index 1, [2,2], forms a non-decreasing subarray of length 2.
We can show that 2 is the maximum achievable length.

Example 2:

Input: nums1 = [1,3,2,1], nums2 = [2,2,3,4]
Output: 4
Explanation: One way to construct nums3 is:
nums3 = [nums1[0], nums2[1], nums2[2], nums2[3]] => [1,2,3,4].
The entire array forms a non-decreasing subarray of length 4, making it the maximum achievable length.

Example 3:

Input: nums1 = [1,1], nums2 = [2,2]
Output: 2
Explanation: One way to construct nums3 is:
nums3 = [nums1[0], nums1[1]] => [1,1].
The entire array forms a non-decreasing subarray of length 2, making it the maximum achievable length.

Constraints:

 * 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:

You are given two 0-indexed integer arrays nums1 and nums2 of length n.

Let's define another 0-indexed integer array, nums3, of length n. For each index i in the range [0, n - 1], you can assign either nums1[i] or nums2[i] to nums3[i].

Your task is to maximize the length of the longest non-decreasing subarray in nums3 by choosing its values optimally.

Return an integer representing the length of the longest non-decreasing subarray in nums3.

Note: A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums1 = [2,3,1], nums2 = [1,2,1]
Output: 2
Explanation: One way to construct nums3 is:
nums3 = [nums1[0], nums2[1], nums2[2]] => [2,2,1].
The subarray starting from index 0 and ending at index 1, [2,2], forms a non-decreasing subarray of length 2.
We can show that 2 is the maximum achievable length.

Example 2:

Input: nums1 = [1,3,2,1], nums2 = [2,2,3,4]
Output: 4
Explanation: One way to construct nums3 is:
nums3 = [nums1[0], nums2[1], nums2[2], nums2[3]] => [1,2,3,4].
The entire array forms a non-decreasing subarray of length 4, making it the maximum achievable length.

Example 3:

Input: nums1 = [1,1], nums2 = [2,2]
Output: 2
Explanation: One way to construct nums3 is:
nums3 = [nums1[0], nums1[1]] => [1,1].
The entire array forms a non-decreasing subarray of length 2, making it the maximum achievable length.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed integer array nums and a positive integer k.

You can apply the following operation on the array any number of times:

 * Choose any subarray of size k from the array and decrease all its elements by 1.

Return true if you can make all the array elements equal to 0, or false otherwise.

A subarray is a contiguous non-empty part of an array.

Example 1:

Input: nums = [2,2,3,1,1,0], k = 3
Output: true
Explanation: We can do the following operations:
- Choose the subarray [2,2,3]. The resulting array will be nums = [1,1,2,1,1,0].
- Choose the subarray [2,1,1]. The resulting array will be nums = [1,1,1,0,0,0].
- Choose the subarray [1,1,1]. The resulting array will be nums = [0,0,0,0,0,0].

Example 2:

Input: nums = [1,3,1,1], k = 2
Output: false
Explanation: It is not possible to make all the array elements equal to 0.

Constraints:

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

You are given a 0-indexed integer array nums and a positive integer k.

You can apply the following operation on the array any number of times:

 * Choose any subarray of size k from the array and decrease all its elements by 1.

Return true if you can make all the array elements equal to 0, or false otherwise.

A subarray is a contiguous non-empty part of an array.

Example 1:

Input: nums = [2,2,3,1,1,0], k = 3
Output: true
Explanation: We can do the following operations:
- Choose the subarray [2,2,3]. The resulting array will be nums = [1,1,2,1,1,0].
- Choose the subarray [2,1,1]. The resulting array will be nums = [1,1,1,0,0,0].
- Choose the subarray [1,1,1]. The resulting array will be nums = [0,0,0,0,0,0].

Example 2:

Input: nums = [1,3,1,1], k = 2
Output: false
Explanation: It is not possible to make all the array elements equal to 0.

Constraints:

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

Please complete the code below to solve above prblem:
```python
class Solution:
    def checkArray(self, nums: List[int], k: int) -> bool:

```


longest-alternating-subarray

Longest Alternating Subarray

Prompt:
"""
You are given a 0-indexed integer array nums. A subarray s of length m is called alternating if:

 * m is greater than 1.
 * s1 = s0 + 1.
 * The 0-indexed subarray s looks like [s0, s1, s0, s1,...,s(m-1) % 2]. In other words, s1 - s0 = 1, s2 - s1 = -1, s3 - s2 = 1, s4 - s3 = -1, and so on up to s[m - 1] - s[m - 2] = (-1)m.

Return the maximum length of all alternating subarrays present in nums or -1 if no such subarray exists.

A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [2,3,4,3,4]
Output: 4
Explanation: The alternating subarrays are [3,4], [3,4,3], and [3,4,3,4]. The longest of these is [3,4,3,4], which is of length 4.

Example 2:

Input: nums = [4,5,6]
Output: 2
Explanation: [4,5] and [5,6] are the only two alternating subarrays. They are both of length 2.

Constraints:

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

You are given a 0-indexed integer array nums. A subarray s of length m is called alternating if:

 * m is greater than 1.
 * s1 = s0 + 1.
 * The 0-indexed subarray s looks like [s0, s1, s0, s1,...,s(m-1) % 2]. In other words, s1 - s0 = 1, s2 - s1 = -1, s3 - s2 = 1, s4 - s3 = -1, and so on up to s[m - 1] - s[m - 2] = (-1)m.

Return the maximum length of all alternating subarrays present in nums or -1 if no such subarray exists.

A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [2,3,4,3,4]
Output: 4
Explanation: The alternating subarrays are [3,4], [3,4,3], and [3,4,3,4]. The longest of these is [3,4,3,4], which is of length 4.

Example 2:

Input: nums = [4,5,6]
Output: 2
Explanation: [4,5] and [5,6] are the only two alternating subarrays. They are both of length 2.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed integer array nums representing the initial positions of some marbles. You are also given two 0-indexed integer arrays moveFrom and moveTo of equal length.

Throughout moveFrom.length steps, you will change the positions of the marbles. On the ith step, you will move all marbles at position moveFrom[i] to position moveTo[i].

After completing all the steps, return the sorted list of occupied positions.

Notes:

 * We call a position occupied if there is at least one marble in that position.
 * There may be multiple marbles in a single position.

Example 1:

Input: nums = [1,6,7,8], moveFrom = [1,7,2], moveTo = [2,9,5]
Output: [5,6,8,9]
Explanation: Initially, the marbles are at positions 1,6,7,8.
At the i = 0th step, we move the marbles at position 1 to position 2. Then, positions 2,6,7,8 are occupied.
At the i = 1st step, we move the marbles at position 7 to position 9. Then, positions 2,6,8,9 are occupied.
At the i = 2nd step, we move the marbles at position 2 to position 5. Then, positions 5,6,8,9 are occupied.
At the end, the final positions containing at least one marbles are [5,6,8,9].

Example 2:

Input: nums = [1,1,3,3], moveFrom = [1,3], moveTo = [2,2]
Output: [2]
Explanation: Initially, the marbles are at positions [1,1,3,3].
At the i = 0th step, we move all the marbles at position 1 to position 2. Then, the marbles are at positions [2,2,3,3].
At the i = 1st step, we move all the marbles at position 3 to position 2. Then, the marbles are at positions [2,2,2,2].
Since 2 is the only occupied position, we return [2].

Constraints:

 * 1 <= nums.length <= 105
 * 1 <= moveFrom.length <= 105
 * moveFrom.length == moveTo.length
 * 1 <= nums[i], moveFrom[i], moveTo[i] <= 109
 * The test cases are generated such that there is at least a marble in moveFrom[i] at the moment we want to apply the ith move.
"""
class Solution:
    def relocateMarbles(self, nums: List[int], moveFrom: List[int], moveTo: List[int]) -> List[int]:

You are given a 0-indexed integer array nums representing the initial positions of some marbles. You are also given two 0-indexed integer arrays moveFrom and moveTo of equal length.

Throughout moveFrom.length steps, you will change the positions of the marbles. On the ith step, you will move all marbles at position moveFrom[i] to position moveTo[i].

After completing all the steps, return the sorted list of occupied positions.

Notes:

 * We call a position occupied if there is at least one marble in that position.
 * There may be multiple marbles in a single position.

Example 1:

Input: nums = [1,6,7,8], moveFrom = [1,7,2], moveTo = [2,9,5]
Output: [5,6,8,9]
Explanation: Initially, the marbles are at positions 1,6,7,8.
At the i = 0th step, we move the marbles at position 1 to position 2. Then, positions 2,6,7,8 are occupied.
At the i = 1st step, we move the marbles at position 7 to position 9. Then, positions 2,6,8,9 are occupied.
At the i = 2nd step, we move the marbles at position 2 to position 5. Then, positions 5,6,8,9 are occupied.
At the end, the final positions containing at least one marbles are [5,6,8,9].

Example 2:

Input: nums = [1,1,3,3], moveFrom = [1,3], moveTo = [2,2]
Output: [2]
Explanation: Initially, the marbles are at positions [1,1,3,3].
At the i = 0th step, we move all the marbles at position 1 to position 2. Then, the marbles are at positions [2,2,3,3].
At the i = 1st step, we move all the marbles at position 3 to position 2. Then, the marbles are at positions [2,2,2,2].
Since 2 is the only occupied position, we return [2].

Constraints:

 * 1 <= nums.length <= 105
 * 1 <= moveFrom.length <= 105
 * moveFrom.length == moveTo.length
 * 1 <= nums[i], moveFrom[i], moveTo[i] <= 109
 * The test cases are generated such that there is at least a marble in moveFrom[i] at the moment we want to apply the ith move.

Please complete the code below to solve above prblem:
```python
class Solution:
    def relocateMarbles(self, nums: List[int], moveFrom: List[int], moveTo: List[int]) -> List[int]:

```