length-of-longest-subarray-with-at-most-k-frequency

Length of Longest Subarray With at Most K Frequency

Prompt:
"""
给你一个整数数组nums和一个整数k。
一个元素 x在数组中的 频率指的是它在数组中的出现次数。
如果一个数组中所有元素的频率都 小于等于k，那么我们称这个数组是 好数组。
请你返回 nums中 最长好子数组的长度。
子数组 指的是一个数组中一段连续非空的元素序列。

示例 1：

输入：nums = [1,2,3,1,2,3,1,2], k = 2
输出：6
解释：最长好子数组是 [1,2,3,1,2,3] ，值 1 ，2 和 3 在子数组中的频率都没有超过 k = 2 。[2,3,1,2,3,1] 和 [3,1,2,3,1,2] 也是好子数组。
最长好子数组的长度为 6 。

示例 2：

输入：nums = [1,2,1,2,1,2,1,2], k = 1
输出：2
解释：最长好子数组是 [1,2] ，值 1 和 2 在子数组中的频率都没有超过 k = 1 。[2,1] 也是好子数组。
最长好子数组的长度为 2 。

示例 3：

输入：nums = [5,5,5,5,5,5,5], k = 4
输出：4
解释：最长好子数组是 [5,5,5,5] ，值 5 在子数组中的频率没有超过 k = 4 。
最长好子数组的长度为 4 。

提示：

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

给你一个整数数组nums和一个整数k。
一个元素 x在数组中的 频率指的是它在数组中的出现次数。
如果一个数组中所有元素的频率都 小于等于k，那么我们称这个数组是 好数组。
请你返回 nums中 最长好子数组的长度。
子数组 指的是一个数组中一段连续非空的元素序列。

示例 1：

输入：nums = [1,2,3,1,2,3,1,2], k = 2
输出：6
解释：最长好子数组是 [1,2,3,1,2,3] ，值 1 ，2 和 3 在子数组中的频率都没有超过 k = 2 。[2,3,1,2,3,1] 和 [3,1,2,3,1,2] 也是好子数组。
最长好子数组的长度为 6 。

示例 2：

输入：nums = [1,2,1,2,1,2,1,2], k = 1
输出：2
解释：最长好子数组是 [1,2] ，值 1 和 2 在子数组中的频率都没有超过 k = 1 。[2,1] 也是好子数组。
最长好子数组的长度为 2 。

示例 3：

输入：nums = [5,5,5,5,5,5,5], k = 4
输出：4
解释：最长好子数组是 [5,5,5,5] ，值 5 在子数组中的频率没有超过 k = 4 。
最长好子数组的长度为 4 。

提示：

1 <= nums.length <= 105
1 <= nums[i] <= 109
1 <= k <= nums.length

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

```

my_solution = Solution()

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

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

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

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

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

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

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

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

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

test_input = { "nums": [7], "k": 1 }
assert my_solution.maxSubarrayLength(**test_input) == 1

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

test_input = { "nums": [9], "k": 1 }
assert my_solution.maxSubarrayLength(**test_input) == 1

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

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

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

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

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

test_input = { "nums": [5,8], "k": 2 }
assert my_solution.maxSubarrayLength(**test_input) == 2

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

test_input = { "nums": [7,9], "k": 2 }
assert my_solution.maxSubarrayLength(**test_input) == 2

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

test_input = { "nums": [9,8], "k": 1 }
assert my_solution.maxSubarrayLength(**test_input) == 2

test_input = { "nums": [10,5], "k": 1 }
assert my_solution.maxSubarrayLength(**test_input) == 2

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

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

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

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

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

test_input = { "nums": [1,3,5], "k": 1 }
assert my_solution.maxSubarrayLength(**test_input) == 3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [2,8,5], "k": 2 }
assert my_solution.maxSubarrayLength(**test_input) == 3

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

test_input = { "nums": [2,9,5], "k": 1 }
assert my_solution.maxSubarrayLength(**test_input) == 3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [3,7,5], "k": 1 }
assert my_solution.maxSubarrayLength(**test_input) == 3

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

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

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

test_input = { "nums": [3,9,1], "k": 1 }
assert my_solution.maxSubarrayLength(**test_input) == 3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


number-of-possible-sets-of-closing-branches

Number of Possible Sets of Closing Branches

Prompt:
"""
一个公司在全国有 n个分部，它们之间有的有道路连接。一开始，所有分部通过这些道路两两之间互相可以到达。
公司意识到在分部之间旅行花费了太多时间，所以它们决定关闭一些分部（也可能不关闭任何分部），同时保证剩下的分部之间两两互相可以到达且最远距离不超过maxDistance。
两个分部之间的 距离 是通过道路长度之和的 最小值。
给你整数n，maxDistance和下标从 0开始的二维整数数组roads，其中roads[i] = [ui, vi, wi]表示一条从ui到vi长度为wi的无向道路。
请你返回关闭分部的可行方案数目，满足每个方案里剩余分部之间的最远距离不超过maxDistance。
注意，关闭一个分部后，与之相连的所有道路不可通行。
注意，两个分部之间可能会有多条道路。

示例 1：

输入：n = 3, maxDistance = 5, roads = [[0,1,2],[1,2,10],[0,2,10]]
输出：5
解释：可行的关闭分部方案有：
- 关闭分部集合 [2] ，剩余分部为 [0,1] ，它们之间的距离为 2 。
- 关闭分部集合 [0,1] ，剩余分部为 [2] 。
- 关闭分部集合 [1,2] ，剩余分部为 [0] 。
- 关闭分部集合 [0,2] ，剩余分部为 [1] 。
- 关闭分部集合 [0,1,2] ，关闭后没有剩余分部。
总共有 5 种可行的关闭方案。

示例 2：

输入：n = 3, maxDistance = 5, roads = [[0,1,20],[0,1,10],[1,2,2],[0,2,2]]
输出：7
解释：可行的关闭分部方案有：
- 关闭分部集合 [] ，剩余分部为 [0,1,2] ，它们之间的最远距离为 4 。
- 关闭分部集合 [0] ，剩余分部为 [1,2] ，它们之间的距离为 2 。
- 关闭分部集合 [1] ，剩余分部为 [0,2] ，它们之间的距离为 2 。
- 关闭分部集合 [0,1] ，剩余分部为 [2] 。
- 关闭分部集合 [1,2] ，剩余分部为 [0] 。
- 关闭分部集合 [0,2] ，剩余分部为 [1] 。
- 关闭分部集合 [0,1,2] ，关闭后没有剩余分部。
总共有 7 种可行的关闭方案。

示例 3：

输入：n = 1, maxDistance = 10, roads = []
输出：2
解释：可行的关闭分部方案有：
- 关闭分部集合 [] ，剩余分部为 [0] 。
- 关闭分部集合 [0] ，关闭后没有剩余分部。
总共有 2 种可行的关闭方案。

提示：

1 <= n <= 10
1 <= maxDistance <= 105
0 <= roads.length <= 1000
roads[i].length == 3
0 <= ui, vi <= n - 1
ui != vi
1 <= wi <= 1000
一开始所有分部之间通过道路互相可以到达。
"""
class Solution:
    def numberOfSets(self, n: int, maxDistance: int, roads: List[List[int]]) -> int:

一个公司在全国有 n个分部，它们之间有的有道路连接。一开始，所有分部通过这些道路两两之间互相可以到达。
公司意识到在分部之间旅行花费了太多时间，所以它们决定关闭一些分部（也可能不关闭任何分部），同时保证剩下的分部之间两两互相可以到达且最远距离不超过maxDistance。
两个分部之间的 距离 是通过道路长度之和的 最小值。
给你整数n，maxDistance和下标从 0开始的二维整数数组roads，其中roads[i] = [ui, vi, wi]表示一条从ui到vi长度为wi的无向道路。
请你返回关闭分部的可行方案数目，满足每个方案里剩余分部之间的最远距离不超过maxDistance。
注意，关闭一个分部后，与之相连的所有道路不可通行。
注意，两个分部之间可能会有多条道路。

示例 1：

输入：n = 3, maxDistance = 5, roads = [[0,1,2],[1,2,10],[0,2,10]]
输出：5
解释：可行的关闭分部方案有：
- 关闭分部集合 [2] ，剩余分部为 [0,1] ，它们之间的距离为 2 。
- 关闭分部集合 [0,1] ，剩余分部为 [2] 。
- 关闭分部集合 [1,2] ，剩余分部为 [0] 。
- 关闭分部集合 [0,2] ，剩余分部为 [1] 。
- 关闭分部集合 [0,1,2] ，关闭后没有剩余分部。
总共有 5 种可行的关闭方案。

示例 2：

输入：n = 3, maxDistance = 5, roads = [[0,1,20],[0,1,10],[1,2,2],[0,2,2]]
输出：7
解释：可行的关闭分部方案有：
- 关闭分部集合 [] ，剩余分部为 [0,1,2] ，它们之间的最远距离为 4 。
- 关闭分部集合 [0] ，剩余分部为 [1,2] ，它们之间的距离为 2 。
- 关闭分部集合 [1] ，剩余分部为 [0,2] ，它们之间的距离为 2 。
- 关闭分部集合 [0,1] ，剩余分部为 [2] 。
- 关闭分部集合 [1,2] ，剩余分部为 [0] 。
- 关闭分部集合 [0,2] ，剩余分部为 [1] 。
- 关闭分部集合 [0,1,2] ，关闭后没有剩余分部。
总共有 7 种可行的关闭方案。

示例 3：

输入：n = 1, maxDistance = 10, roads = []
输出：2
解释：可行的关闭分部方案有：
- 关闭分部集合 [] ，剩余分部为 [0] 。
- 关闭分部集合 [0] ，关闭后没有剩余分部。
总共有 2 种可行的关闭方案。

提示：

1 <= n <= 10
1 <= maxDistance <= 105
0 <= roads.length <= 1000
roads[i].length == 3
0 <= ui, vi <= n - 1
ui != vi
1 <= wi <= 1000
一开始所有分部之间通过道路互相可以到达。

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

```

my_solution = Solution()

test_input = { "n": 3, "maxDistance": 5, "roads": [[0,1,2],[1,2,10],[0,2,10]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 3, "maxDistance": 5, "roads": [[0,1,20],[0,1,10],[1,2,2],[0,2,2]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 1, "maxDistance": 10, "roads": [] }
assert my_solution.numberOfSets(**test_input) == 2

test_input = { "n": 3, "maxDistance": 12, "roads": [[1,0,11],[1,0,16],[0,2,13]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 3, "maxDistance": 3, "roads": [[2,0,14],[1,0,15],[1,0,7]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 3, "maxDistance": 19, "roads": [[1,0,7],[0,2,18]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 3, "maxDistance": 5, "roads": [[2,0,4],[1,0,3],[1,0,2]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 4, "maxDistance": 3, "roads": [[2,1,8],[1,0,3],[0,3,8]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 5, "maxDistance": 20, "roads": [[3,2,20],[1,0,10],[0,2,19],[0,3,13],[0,4,19]] }
assert my_solution.numberOfSets(**test_input) == 12

test_input = { "n": 2, "maxDistance": 30, "roads": [[1,0,33]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 3, "maxDistance": 12, "roads": [[2,1,4],[0,1,4],[0,2,6]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 3, "maxDistance": 3, "roads": [[1,0,4],[0,2,5]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 3, "maxDistance": 27, "roads": [[2,1,23],[0,1,14],[0,2,18]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 4, "maxDistance": 20, "roads": [[2,0,16],[0,1,13],[0,3,11]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 3, "maxDistance": 22, "roads": [[1,0,21],[2,1,28]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 2, "maxDistance": 2, "roads": [[1,0,6]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 3, "maxDistance": 22, "roads": [[1,0,16],[1,0,12],[0,2,14]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 2, "maxDistance": 8, "roads": [[1,0,9]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 2, "maxDistance": 18, "roads": [[1,0,3]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 4, "maxDistance": 27, "roads": [[3,2,3],[0,1,27],[0,2,6],[0,3,17]] }
assert my_solution.numberOfSets(**test_input) == 10

test_input = { "n": 5, "maxDistance": 14, "roads": [[1,0,13],[2,0,19],[0,3,16],[0,4,18]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 5, "maxDistance": 8, "roads": [[1,0,3],[3,1,10],[4,0,6],[2,0,9],[3,2,11],[4,0,12]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 2, "maxDistance": 4, "roads": [[1,0,7]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 4, "maxDistance": 39, "roads": [[2,0,44],[3,2,42],[2,1,45]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 5, "maxDistance": 2, "roads": [[4,1,11],[3,1,5],[1,0,4],[0,2,7]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 3, "maxDistance": 9, "roads": [[1,0,17],[0,2,22]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 2, "maxDistance": 1, "roads": [[1,0,3]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 3, "maxDistance": 39, "roads": [[1,0,28],[0,2,35]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 4, "maxDistance": 17, "roads": [[2,1,28],[2,0,6],[1,0,28],[1,0,24],[1,0,18],[1,0,25],[0,3,10]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 5, "maxDistance": 16, "roads": [[2,1,27],[3,0,22],[2,1,4],[1,0,11],[2,1,48],[1,0,40],[4,2,33],[4,3,44],[1,0,1]] }
assert my_solution.numberOfSets(**test_input) == 9

test_input = { "n": 3, "maxDistance": 23, "roads": [[2,1,20],[0,1,12],[0,2,10]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 5, "maxDistance": 3, "roads": [[4,0,5],[1,0,2],[3,0,5],[3,0,4],[4,2,5],[4,2,1]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 3, "maxDistance": 5, "roads": [[1,0,6],[2,0,7]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 3, "maxDistance": 21, "roads": [[2,1,30],[0,1,36],[0,2,44]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 5, "maxDistance": 25, "roads": [[1,0,17],[1,0,1],[2,1,24],[3,2,12],[1,0,7],[3,2,4],[2,1,15],[0,4,14]] }
assert my_solution.numberOfSets(**test_input) == 14

test_input = { "n": 2, "maxDistance": 3, "roads": [[1,0,6]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 3, "maxDistance": 4, "roads": [[1,0,6],[2,1,6],[2,0,2]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 4, "maxDistance": 21, "roads": [[3,2,18],[1,0,15],[2,1,15],[3,0,19],[3,2,19]] }
assert my_solution.numberOfSets(**test_input) == 9

test_input = { "n": 4, "maxDistance": 1, "roads": [[1,0,4],[1,0,2],[3,1,2],[2,1,1],[1,0,3],[2,0,3]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 3, "maxDistance": 33, "roads": [[2,1,2],[1,0,40],[2,1,43]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 4, "maxDistance": 29, "roads": [[2,1,20],[1,0,38],[2,1,15],[2,0,32],[0,3,18]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 3, "maxDistance": 1, "roads": [[2,1,4],[2,0,2],[1,0,12]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 2, "maxDistance": 2, "roads": [[1,0,3]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 3, "maxDistance": 13, "roads": [[1,0,18],[2,0,1],[2,1,2]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 3, "maxDistance": 1, "roads": [[1,0,23],[0,2,37]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 3, "maxDistance": 18, "roads": [[2,0,39],[0,1,47]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 4, "maxDistance": 6, "roads": [[3,0,6],[0,1,3],[0,2,9]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 3, "maxDistance": 35, "roads": [[1,0,10],[1,0,15],[0,2,32]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 5, "maxDistance": 10, "roads": [[4,0,38],[4,0,11],[2,0,24],[3,0,5],[2,1,18],[2,0,38],[1,0,7],[2,1,3],[2,1,2],[3,1,36]] }
assert my_solution.numberOfSets(**test_input) == 10

test_input = { "n": 5, "maxDistance": 16, "roads": [[2,0,32],[4,0,17],[2,0,22],[3,1,38],[3,0,13],[3,1,34],[3,1,36],[1,0,36],[3,1,18],[3,2,10]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 2, "maxDistance": 4, "roads": [[1,0,18]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 5, "maxDistance": 13, "roads": [[3,0,5],[2,1,3],[1,0,6],[3,2,19],[2,1,29],[2,1,30],[1,0,5],[2,0,29],[4,3,15],[2,1,23]] }
assert my_solution.numberOfSets(**test_input) == 12

test_input = { "n": 3, "maxDistance": 23, "roads": [[2,1,12],[1,0,8],[2,1,7]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 5, "maxDistance": 38, "roads": [[2,0,8],[2,1,10],[0,3,25],[0,4,48]] }
assert my_solution.numberOfSets(**test_input) == 11

test_input = { "n": 2, "maxDistance": 4, "roads": [[1,0,2]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 4, "maxDistance": 12, "roads": [[2,1,18],[0,1,25],[0,2,24],[0,3,16]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 4, "maxDistance": 1, "roads": [[2,0,1],[3,2,2],[2,0,2],[2,0,1],[1,0,1],[1,0,1]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 3, "maxDistance": 1, "roads": [[1,0,1],[0,2,1]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 2, "maxDistance": 3, "roads": [[1,0,24]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 2, "maxDistance": 10, "roads": [[1,0,13]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 3, "maxDistance": 1, "roads": [[2,1,1],[0,1,1],[0,2,1]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 5, "maxDistance": 13, "roads": [[1,0,17],[1,0,21],[3,0,9],[1,0,10],[2,0,11],[4,1,12],[2,1,11],[1,0,18]] }
assert my_solution.numberOfSets(**test_input) == 12

test_input = { "n": 2, "maxDistance": 19, "roads": [[1,0,28]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 3, "maxDistance": 8, "roads": [[2,0,7],[2,0,28],[0,1,34]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 5, "maxDistance": 7, "roads": [[1,0,32],[0,2,35],[0,3,20],[0,4,27]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 4, "maxDistance": 1, "roads": [[1,0,4],[1,0,3],[3,0,4],[1,0,7],[0,2,11]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 2, "maxDistance": 34, "roads": [[1,0,11]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 5, "maxDistance": 10, "roads": [[2,1,32],[4,3,14],[3,2,3],[2,1,21],[3,1,37],[2,1,30],[0,1,18],[0,2,26],[0,3,19],[0,4,23]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 5, "maxDistance": 14, "roads": [[2,0,19],[3,1,24],[4,3,10],[4,1,15],[0,1,21],[0,3,21],[0,4,12]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 4, "maxDistance": 30, "roads": [[2,0,5],[0,1,27],[0,3,24]] }
assert my_solution.numberOfSets(**test_input) == 9

test_input = { "n": 2, "maxDistance": 6, "roads": [[1,0,23]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 5, "maxDistance": 6, "roads": [[4,0,17],[2,1,7],[4,1,23],[1,0,1],[1,0,19],[0,3,20]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 3, "maxDistance": 5, "roads": [[1,0,1],[1,0,3],[2,0,4]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 4, "maxDistance": 19, "roads": [[3,2,21],[2,1,3],[0,1,15],[0,2,22],[0,3,8]] }
assert my_solution.numberOfSets(**test_input) == 9

test_input = { "n": 2, "maxDistance": 5, "roads": [[1,0,4]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 4, "maxDistance": 18, "roads": [[2,1,7],[2,0,5],[0,3,10]] }
assert my_solution.numberOfSets(**test_input) == 10

test_input = { "n": 5, "maxDistance": 35, "roads": [[1,0,39],[1,0,3],[3,1,45],[2,0,21],[3,2,40],[3,0,27],[2,1,44],[4,2,6],[4,2,45],[3,0,22]] }
assert my_solution.numberOfSets(**test_input) == 14

test_input = { "n": 4, "maxDistance": 2, "roads": [[1,0,2],[1,0,3],[1,0,15],[1,0,7],[0,2,4],[0,3,6]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 4, "maxDistance": 5, "roads": [[2,0,1],[1,0,3],[0,3,4]] }
assert my_solution.numberOfSets(**test_input) == 10

test_input = { "n": 3, "maxDistance": 19, "roads": [[1,0,9],[0,2,4]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 4, "maxDistance": 1, "roads": [[3,0,4],[2,1,4],[1,0,4]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 2, "maxDistance": 29, "roads": [[1,0,18]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 2, "maxDistance": 11, "roads": [[1,0,28]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 2, "maxDistance": 12, "roads": [[1,0,10]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 5, "maxDistance": 9, "roads": [[3,2,23],[4,3,11],[1,0,16],[2,0,11],[2,0,16],[1,0,20],[4,0,16],[2,0,36],[3,0,7]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 5, "maxDistance": 17, "roads": [[3,2,22],[3,2,3],[4,0,19],[3,0,21],[4,3,4],[1,0,24],[3,0,7],[3,2,12],[1,0,17]] }
assert my_solution.numberOfSets(**test_input) == 14

test_input = { "n": 4, "maxDistance": 5, "roads": [[2,0,26],[1,0,15],[3,2,17]] }
assert my_solution.numberOfSets(**test_input) == 5

test_input = { "n": 4, "maxDistance": 4, "roads": [[1,0,11],[0,2,3],[0,3,3]] }
assert my_solution.numberOfSets(**test_input) == 7

test_input = { "n": 5, "maxDistance": 13, "roads": [[3,1,16],[0,1,3],[0,2,19],[0,3,10],[0,4,2]] }
assert my_solution.numberOfSets(**test_input) == 13

test_input = { "n": 4, "maxDistance": 5, "roads": [[1,0,21],[1,0,13],[1,0,19],[2,1,15],[1,0,17],[1,0,3],[0,3,1]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 5, "maxDistance": 25, "roads": [[1,0,18],[3,0,20],[2,0,17],[2,1,21],[0,4,3]] }
assert my_solution.numberOfSets(**test_input) == 16

test_input = { "n": 5, "maxDistance": 15, "roads": [[2,1,33],[1,0,18],[2,0,16],[3,1,37],[3,0,26],[0,4,18]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 4, "maxDistance": 1, "roads": [[1,0,1],[1,0,1],[0,2,1],[0,3,1]] }
assert my_solution.numberOfSets(**test_input) == 8

test_input = { "n": 4, "maxDistance": 10, "roads": [[2,0,22],[2,1,6],[2,0,21],[2,1,27],[3,1,12]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 2, "maxDistance": 13, "roads": [[1,0,21]] }
assert my_solution.numberOfSets(**test_input) == 3

test_input = { "n": 4, "maxDistance": 31, "roads": [[3,1,7],[2,1,10],[2,0,25],[2,0,27]] }
assert my_solution.numberOfSets(**test_input) == 9

test_input = { "n": 3, "maxDistance": 17, "roads": [[1,0,8],[1,0,8],[0,2,14]] }
assert my_solution.numberOfSets(**test_input) == 6

test_input = { "n": 2, "maxDistance": 3, "roads": [[1,0,3]] }
assert my_solution.numberOfSets(**test_input) == 4

test_input = { "n": 5, "maxDistance": 5, "roads": [[4,1,37],[4,1,7],[2,1,6],[3,2,8],[2,1,35],[1,0,28],[4,1,3],[2,1,2]] }
assert my_solution.numberOfSets(**test_input) == 9

test_input = { "n": 4, "maxDistance": 1, "roads": [[2,0,2],[2,0,1],[0,1,2],[0,3,2]] }
assert my_solution.numberOfSets(**test_input) == 6


find-the-peaks

Find the Peaks

Prompt:
"""
给你一个下标从 0 开始的数组 mountain 。你的任务是找出数组mountain 中的所有 峰值。
以数组形式返回给定数组中 峰值 的下标，顺序不限 。
注意：

峰值 是指一个严格大于其相邻元素的元素。
数组的第一个和最后一个元素 不 是峰值。

示例 1：

输入：mountain = [2,4,4]
输出：[]
解释：mountain[0] 和 mountain[2] 不可能是峰值，因为它们是数组的第一个和最后一个元素。
mountain[1] 也不可能是峰值，因为它不严格大于 mountain[2] 。
因此，答案为 [] 。

示例 2：

输入：mountain = [1,4,3,8,5]
输出：[1,3]
解释：mountain[0] 和 mountain[4] 不可能是峰值，因为它们是数组的第一个和最后一个元素。
mountain[2] 也不可能是峰值，因为它不严格大于 mountain[3] 和 mountain[1] 。
但是 mountain[1] 和 mountain[3] 严格大于它们的相邻元素。
因此，答案是 [1,3] 。

提示：

3 <= mountain.length <= 100
1 <= mountain[i] <= 100
"""
class Solution:
    def findPeaks(self, mountain: List[int]) -> List[int]:

给你一个下标从 0 开始的数组 mountain 。你的任务是找出数组mountain 中的所有 峰值。
以数组形式返回给定数组中 峰值 的下标，顺序不限 。
注意：

峰值 是指一个严格大于其相邻元素的元素。
数组的第一个和最后一个元素 不 是峰值。

示例 1：

输入：mountain = [2,4,4]
输出：[]
解释：mountain[0] 和 mountain[2] 不可能是峰值，因为它们是数组的第一个和最后一个元素。
mountain[1] 也不可能是峰值，因为它不严格大于 mountain[2] 。
因此，答案为 [] 。

示例 2：

输入：mountain = [1,4,3,8,5]
输出：[1,3]
解释：mountain[0] 和 mountain[4] 不可能是峰值，因为它们是数组的第一个和最后一个元素。
mountain[2] 也不可能是峰值，因为它不严格大于 mountain[3] 和 mountain[1] 。
但是 mountain[1] 和 mountain[3] 严格大于它们的相邻元素。
因此，答案是 [1,3] 。

提示：

3 <= mountain.length <= 100
1 <= mountain[i] <= 100

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

```

my_solution = Solution()

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

test_input = { "mountain": [1,4,3,8,5] }
assert my_solution.findPeaks(**test_input) == [1,3]

test_input = { "mountain": [1,1,1] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,1,3] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,1,5] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,2,5] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,4,1] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [1,4,3] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [1,5,5] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,6,4] }
assert my_solution.findPeaks(**test_input) == [1]

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

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

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

test_input = { "mountain": [2,2,5] }
assert my_solution.findPeaks(**test_input) == []

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

test_input = { "mountain": [2,3,6] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [2,4,3] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [2,4,5] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [2,6,4] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [3,3,3] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [3,3,5] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [3,4,6] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [3,5,1] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [3,5,3] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [3,5,4] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [3,5,6] }
assert my_solution.findPeaks(**test_input) == []

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

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

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

test_input = { "mountain": [4,2,6] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [4,4,1] }
assert my_solution.findPeaks(**test_input) == []

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

test_input = { "mountain": [4,4,5] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [4,5,4] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [4,6,1] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [4,6,6] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,1,2] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,2,1] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,2,2] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,2,4] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,3,1] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,5,1] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,5,2] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,5,6] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,6,1] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [5,6,4] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [6,1,1] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,1,2] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,1,5] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,2,2] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,2,5] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,3,2] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,3,3] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,3,6] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,4,3] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [6,5,2] }
assert my_solution.findPeaks(**test_input) == []

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

test_input = { "mountain": [6,6,4] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,1,1,4] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,1,7,7] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,3,6,5] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [1,4,7,8] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,6,6,6] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [1,8,1,8] }
assert my_solution.findPeaks(**test_input) == [1]

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

test_input = { "mountain": [2,3,7,6] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [2,5,4,5] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [2,7,1,2] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [2,7,2,6] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [2,7,5,3] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [2,7,7,6] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [3,1,2,5] }
assert my_solution.findPeaks(**test_input) == []

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

test_input = { "mountain": [3,3,7,8] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [3,4,2,4] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [3,4,5,4] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [3,4,7,6] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [3,5,5,3] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [3,6,4,7] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [3,8,5,5] }
assert my_solution.findPeaks(**test_input) == [1]

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

test_input = { "mountain": [4,2,6,8] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [4,3,3,8] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [4,4,8,7] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [4,5,1,1] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [4,6,1,7] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [4,6,2,1] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [4,6,2,2] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [5,1,7,6] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [5,3,2,2] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,3,6,3] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [5,3,8,3] }
assert my_solution.findPeaks(**test_input) == [2]

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

test_input = { "mountain": [5,4,4,8] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,5,1,7] }
assert my_solution.findPeaks(**test_input) == []

test_input = { "mountain": [5,5,8,2] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [5,6,7,4] }
assert my_solution.findPeaks(**test_input) == [2]

test_input = { "mountain": [5,7,4,3] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [5,8,7,8] }
assert my_solution.findPeaks(**test_input) == [1]

test_input = { "mountain": [6,2,8,6] }
assert my_solution.findPeaks(**test_input) == [2]


minimum-number-of-coins-to-be-added

Minimum Number of Coins to be Added

Prompt:
"""
给你一个下标从 0 开始的整数数组 coins，表示可用的硬币的面值，以及一个整数 target 。
如果存在某个 coins 的子序列总和为 x，那么整数 x 就是一个 可取得的金额 。
返回需要添加到数组中的 任意面值 硬币的 最小数量 ，使范围 [1, target] 内的每个整数都属于 可取得的金额 。
数组的 子序列 是通过删除原始数组的一些（可能不删除）元素而形成的新的 非空 数组，删除过程不会改变剩余元素的相对位置。

示例 1：

输入：coins = [1,4,10], target = 19
输出：2
解释：需要添加面值为 2 和 8 的硬币各一枚，得到硬币数组 [1,2,4,8,10] 。
可以证明从 1 到 19 的所有整数都可由数组中的硬币组合得到，且需要添加到数组中的硬币数目最小为 2 。

示例 2：

输入：coins = [1,4,10,5,7,19], target = 19
输出：1
解释：只需要添加一枚面值为 2 的硬币，得到硬币数组 [1,2,4,5,7,10,19] 。
可以证明从 1 到 19 的所有整数都可由数组中的硬币组合得到，且需要添加到数组中的硬币数目最小为 1 。
示例 3：

输入：coins = [1,1,1], target = 20
输出：3
解释：
需要添加面值为 4 、8 和 16 的硬币各一枚，得到硬币数组 [1,1,1,4,8,16] 。
可以证明从 1 到 20 的所有整数都可由数组中的硬币组合得到，且需要添加到数组中的硬币数目最小为 3 。

提示：

1 <= target <= 105
1 <= coins.length <= 105
1 <= coins[i] <= target
"""
class Solution:
    def minimumAddedCoins(self, coins: List[int], target: int) -> int:

给你一个下标从 0 开始的整数数组 coins，表示可用的硬币的面值，以及一个整数 target 。
如果存在某个 coins 的子序列总和为 x，那么整数 x 就是一个 可取得的金额 。
返回需要添加到数组中的 任意面值 硬币的 最小数量 ，使范围 [1, target] 内的每个整数都属于 可取得的金额 。
数组的 子序列 是通过删除原始数组的一些（可能不删除）元素而形成的新的 非空 数组，删除过程不会改变剩余元素的相对位置。

示例 1：

输入：coins = [1,4,10], target = 19
输出：2
解释：需要添加面值为 2 和 8 的硬币各一枚，得到硬币数组 [1,2,4,8,10] 。
可以证明从 1 到 19 的所有整数都可由数组中的硬币组合得到，且需要添加到数组中的硬币数目最小为 2 。

示例 2：

输入：coins = [1,4,10,5,7,19], target = 19
输出：1
解释：只需要添加一枚面值为 2 的硬币，得到硬币数组 [1,2,4,5,7,10,19] 。
可以证明从 1 到 19 的所有整数都可由数组中的硬币组合得到，且需要添加到数组中的硬币数目最小为 1 。
示例 3：

输入：coins = [1,1,1], target = 20
输出：3
解释：
需要添加面值为 4 、8 和 16 的硬币各一枚，得到硬币数组 [1,1,1,4,8,16] 。
可以证明从 1 到 20 的所有整数都可由数组中的硬币组合得到，且需要添加到数组中的硬币数目最小为 3 。

提示：

1 <= target <= 105
1 <= coins.length <= 105
1 <= coins[i] <= target

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

```

my_solution = Solution()

test_input = { "coins": [1,4,10], "target": 19 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [1,4,10,5,7,19], "target": 19 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [1,1,1], "target": 20 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [1], "target": 100000 }
assert my_solution.minimumAddedCoins(**test_input) == 16

test_input = { "coins": [100000], "target": 100000 }
assert my_solution.minimumAddedCoins(**test_input) == 17

test_input = { "coins": [2], "target": 5 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [5,6,7], "target": 10 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [5,6,7], "target": 15 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [4,11,13,15,7,5,12,11,5,9], "target": 34 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [8,12,9], "target": 27 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [2,13,7,1,11], "target": 35 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [10,3,5,11,6], "target": 27 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [6,6,6,15,4], "target": 31 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [6,15,6], "target": 22 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [8,14,15,4,14,15,8,10,8], "target": 42 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [9,14,14,9,14,5,12,10,11], "target": 17 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [14,5,13,3,7,10,10,10], "target": 32 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [8,6,7,12], "target": 26 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [15,1,12], "target": 43 }
assert my_solution.minimumAddedCoins(**test_input) == 4

test_input = { "coins": [4,1,4,10], "target": 16 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [10,2,13,5,7,15], "target": 26 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [10,1,10], "target": 10 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [9,5,13,8], "target": 30 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [13,9,4,5], "target": 37 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [1,15,5,12,13,10,14,8,1,7], "target": 29 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [14,14,6,2,9,1,4,10], "target": 38 }
assert my_solution.minimumAddedCoins(**test_input) == 0

test_input = { "coins": [7,10,6,14,10,11,2], "target": 45 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [6,3,2,6,8,9,13,3,12,13], "target": 47 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [8,1,9,2,15], "target": 34 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [5,13,9,11,6,1], "target": 27 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [10,15,7,14,2,2,12,14,13], "target": 45 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [9,3,10,3,8,2,7,11,1], "target": 26 }
assert my_solution.minimumAddedCoins(**test_input) == 0

test_input = { "coins": [9,11,2,5,2,7,11], "target": 28 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [5,5,15,3,13], "target": 17 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [2,2,9,10,7,15,4,3,9,15], "target": 16 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [3,1,12,15,5,10], "target": 34 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [12,7,5,2,12], "target": 50 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [11,6,10,3,1,7,11], "target": 44 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [13,12,1,11,3,4,11,9,13,13], "target": 41 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [6,4,1,9,9,2,10,7], "target": 48 }
assert my_solution.minimumAddedCoins(**test_input) == 0

test_input = { "coins": [10,4,4,3,9,6,8,4,7,7], "target": 22 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [15,9,5,7,4,13], "target": 19 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [13,11,8,6,11], "target": 16 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [8,14,15,9,8,10,13,7,3], "target": 42 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [6,14,7,4,10,9,10,9,7], "target": 22 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [4,6,7,15,13,14,5,7], "target": 16 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [10,12,5], "target": 32 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [8,5,14,13,13,11,14,13], "target": 43 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [3,14,4,2,10,3,7], "target": 50 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [1,3,11,9,2,10,6,12], "target": 12 }
assert my_solution.minimumAddedCoins(**test_input) == 0

test_input = { "coins": [2,5,4,12,6,7,11,15], "target": 17 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [7,12,10,15,6,15,14,2,9,12], "target": 24 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [4,7,15,10,14], "target": 38 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [10,1,12,9], "target": 16 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [5,8,12,6,15,13,11,5], "target": 35 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [6,2,6], "target": 39 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [15,10,5,4,7,12,12,5,11], "target": 30 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [9,10,7,12,10,4], "target": 35 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [4,4,2], "target": 8 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [13,4,15,1,8], "target": 25 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [14,7,7,1,6,14,3,15,13], "target": 18 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [8,2,14,2,3,10,15,5], "target": 31 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [3,7,12,10,11,5,3], "target": 36 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [5,3,14,8,10], "target": 33 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [9,14,9,14,4,1,4,12,12], "target": 41 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [6,3,9,7,3,4,4,15,15,10], "target": 47 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [4,9,6], "target": 43 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [12,9,13,12,10,4,9,9,4], "target": 28 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [6,8,2,13,1,5,6], "target": 31 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [9,8,9,9,3,5,10,15,1], "target": 45 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [1,10,15,15], "target": 24 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [9,12,2], "target": 43 }
assert my_solution.minimumAddedCoins(**test_input) == 4

test_input = { "coins": [14,13,10,2,2], "target": 16 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [11,5,5,13,4,13,10,3,4], "target": 21 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [8,9,1,5,8,7,6,8,6], "target": 47 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [4,10,9], "target": 18 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [7,9,7,6,8,11], "target": 50 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [11,6,6,14,12,2], "target": 46 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [8,9,2], "target": 31 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [12,1,4,3,5,3], "target": 18 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [4,3,13], "target": 34 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [9,11,3], "target": 22 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [1,11,15,1,10,13,7,6,12], "target": 28 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [1,10,8,7,12], "target": 19 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [1,5,15,13,8,4,5,7], "target": 29 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [3,8,13,8,5,3,7,2,9,8], "target": 50 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [4,13,12], "target": 47 }
assert my_solution.minimumAddedCoins(**test_input) == 4

test_input = { "coins": [9,3,10,9,11], "target": 48 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [8,7,6,1,9,5,5], "target": 13 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [11,9,1,15], "target": 16 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [8,13,8], "target": 27 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [7,10,11,3,10,14], "target": 36 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [14,9,6,11,13,8,8,5,6], "target": 22 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [9,3,6,10,11,1,5,14,3], "target": 27 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [4,5,9,6,2,2,10,5,13], "target": 43 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [3,10,2,13,6,13,14,14,3], "target": 28 }
assert my_solution.minimumAddedCoins(**test_input) == 1

test_input = { "coins": [14,15,15,12,13,4,15], "target": 38 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [10,5,12,11,9,8,1], "target": 12 }
assert my_solution.minimumAddedCoins(**test_input) == 2

test_input = { "coins": [15,13,12,4], "target": 31 }
assert my_solution.minimumAddedCoins(**test_input) == 3

test_input = { "coins": [4,5,14,13,10,12], "target": 31 }
assert my_solution.minimumAddedCoins(**test_input) == 2


count-complete-substrings

Count Complete Substrings

Prompt:
"""
给你一个字符串word和一个整数 k。
如果word的一个子字符串 s满足以下条件，我们称它是 完全字符串：

s中每个字符 恰好出现 k次。
相邻字符在字母表中的顺序 至多相差2。也就是说，s中两个相邻字符c1 和c2，它们在字母表中的位置相差至多为 2 。

请你返回 word中 完全子字符串的数目。
子字符串指的是一个字符串中一段连续 非空的字符序列。

示例 1：

输入：word = "igigee", k = 2
输出：3
解释：完全子字符串需要满足每个字符恰好出现 2 次，且相邻字符相差至多为 2 ：igigee, igigee, igigee。

示例 2：

输入：word = "aaabbbccc", k = 3
输出：6
解释：完全子字符串需要满足每个字符恰好出现 3 次，且相邻字符相差至多为 2 ：aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc 。

提示：

1 <= word.length <= 105
word只包含小写英文字母。
1 <= k <= word.length
"""
class Solution:
    def countCompleteSubstrings(self, word: str, k: int) -> int:

给你一个字符串word和一个整数 k。
如果word的一个子字符串 s满足以下条件，我们称它是 完全字符串：

s中每个字符 恰好出现 k次。
相邻字符在字母表中的顺序 至多相差2。也就是说，s中两个相邻字符c1 和c2，它们在字母表中的位置相差至多为 2 。

请你返回 word中 完全子字符串的数目。
子字符串指的是一个字符串中一段连续 非空的字符序列。

示例 1：

输入：word = "igigee", k = 2
输出：3
解释：完全子字符串需要满足每个字符恰好出现 2 次，且相邻字符相差至多为 2 ：igigee, igigee, igigee。

示例 2：

输入：word = "aaabbbccc", k = 3
输出：6
解释：完全子字符串需要满足每个字符恰好出现 3 次，且相邻字符相差至多为 2 ：aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc 。

提示：

1 <= word.length <= 105
word只包含小写英文字母。
1 <= k <= word.length

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

```

my_solution = Solution()

test_input = { "word": "igigee", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 3

test_input = { "word": "aaabbbccc", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "a", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "b", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "c", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "aa", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "ab", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "ac", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "ba", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 3

test_input = { "word": "bb", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "bc", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 3

test_input = { "word": "ca", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 3

test_input = { "word": "cb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 3

test_input = { "word": "cc", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "aaa", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 3

test_input = { "word": "aab", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "aac", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "aba", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "abb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 4

test_input = { "word": "abc", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "aca", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 5

test_input = { "word": "acb", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "acc", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "baa", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "bab", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bac", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bba", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 4

test_input = { "word": "bbb", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 2

test_input = { "word": "bbc", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "bca", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bcb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 5

test_input = { "word": "bcc", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "caa", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 4

test_input = { "word": "cab", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "cac", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "cba", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "cbb", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "cbc", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "cca", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "ccb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 4

test_input = { "word": "ccc", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 2

test_input = { "word": "aaaa", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "aaab", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "aaac", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "aaba", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "aabb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 5

test_input = { "word": "aabc", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "aaca", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "aacb", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "aacc", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "abaa", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "abab", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 7

test_input = { "word": "abac", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "abba", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "abbb", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "abbc", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "abca", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 9

test_input = { "word": "abcb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 8

test_input = { "word": "abcc", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "acaa", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "acab", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "acac", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 7

test_input = { "word": "acba", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "acbb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 7

test_input = { "word": "acbc", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "acca", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "accb", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "accc", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "baaa", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 2

test_input = { "word": "baab", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "baac", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "baba", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 7

test_input = { "word": "babb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "babc", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "baca", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bacb", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bacc", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 7

test_input = { "word": "bbaa", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 3

test_input = { "word": "bbab", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bbac", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bbba", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bbbb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 4

test_input = { "word": "bbbc", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "bbca", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bbcb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "bbcc", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bcaa", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "bcab", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bcac", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bcba", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 8

test_input = { "word": "bcbb", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "bcbc", "k": 2 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "bcca", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bccb", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "bccc", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "caaa", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 1

test_input = { "word": "caab", "k": 1 }
assert my_solution.countCompleteSubstrings(**test_input) == 6

test_input = { "word": "caac", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "caba", "k": 4 }
assert my_solution.countCompleteSubstrings(**test_input) == 0

test_input = { "word": "cabb", "k": 3 }
assert my_solution.countCompleteSubstrings(**test_input) == 0


count-the-number-of-infection-sequences

Count the Number of Infection Sequences

Prompt:
"""
给你一个整数n和一个下标从 0开始的整数数组sick，数组按 升序排序。
有n位小朋友站成一排，按顺序编号为 0到 n - 1。数组sick包含一开始得了感冒的小朋友的位置。如果位置为i的小朋友得了感冒，他会传染给下标为 i - 1或者 i + 1的小朋友，前提 是被传染的小朋友存在且还没有得感冒。每一秒中， 至多一位还没感冒的小朋友会被传染。
经过有限的秒数后，队列中所有小朋友都会感冒。感冒序列指的是 所有一开始没有感冒的小朋友最后得感冒的顺序序列。请你返回所有感冒序列的数目。
由于答案可能很大，请你将答案对109 + 7取余后返回。
注意，感冒序列 不 包含一开始就得了感冒的小朋友的下标。

示例 1：

输入：n = 5, sick = [0,4]
输出：4
解释：一开始，下标为 1 ，2 和 3 的小朋友没有感冒。总共有 4 个可能的感冒序列：
- 一开始，下标为 1 和 3 的小朋友可以被传染，因为他们分别挨着有感冒的小朋友 0 和 4 ，令下标为 1 的小朋友先被传染。
然后，下标为 2 的小朋友挨着感冒的小朋友 1 ，下标为 3 的小朋友挨着感冒的小朋友 4 ，两位小朋友都可以被传染，令下标为 2 的小朋友被传染。
最后，下标为 3 的小朋友被传染，因为他挨着感冒的小朋友 2 和 4 ，感冒序列为 [1,2,3] 。
- 一开始，下标为 1 和 3 的小朋友可以被传染，因为他们分别挨着感冒的小朋友 0 和 4 ，令下标为 1 的小朋友先被传染。
然后，下标为 2 的小朋友挨着感冒的小朋友 1 ，下标为 3 的小朋友挨着感冒的小朋友 4 ，两位小朋友都可以被传染，令下标为 3 的小朋友被传染。
最后，下标为 2 的小朋友被传染，因为他挨着感冒的小朋友 1 和 3 ，感冒序列为  [1,3,2] 。
- 感冒序列 [3,1,2] ，被传染的顺序：[0,1,2,3,4] => [0,1,2,3,4] => [0,1,2,3,4] => [0,1,2,3,4] 。
- 感冒序列 [3,2,1] ，被传染的顺序：[0,1,2,3,4] => [0,1,2,3,4] => [0,1,2,3,4] => [0,1,2,3,4] 。

示例 2：

输入：n = 4, sick = [1]
输出：3
解释：一开始，下标为 0 ，2 和 3 的小朋友没有感冒。总共有 3 个可能的感冒序列：
- 感冒序列 [0,2,3] ，被传染的顺序：[0,1,2,3] => [0,1,2,3] => [0,1,2,3] => [0,1,2,3] 。
- 感冒序列 [2,0,3] ，被传染的顺序：[0,1,2,3] => [0,1,2,3] => [0,1,2,3] => [0,1,2,3] 。
- 感冒序列 [2,3,0] ，被传染的顺序：[0,1,2,3] => [0,1,2,3] => [0,1,2,3] => [0,1,2,3] 。

提示：

2 <= n <= 105
1 <= sick.length <= n - 1
0 <= sick[i] <= n - 1
sick按升序排列。
"""
class Solution:
    def numberOfSequence(self, n: int, sick: List[int]) -> int:

给你一个整数n和一个下标从 0开始的整数数组sick，数组按 升序排序。
有n位小朋友站成一排，按顺序编号为 0到 n - 1。数组sick包含一开始得了感冒的小朋友的位置。如果位置为i的小朋友得了感冒，他会传染给下标为 i - 1或者 i + 1的小朋友，前提 是被传染的小朋友存在且还没有得感冒。每一秒中， 至多一位还没感冒的小朋友会被传染。
经过有限的秒数后，队列中所有小朋友都会感冒。感冒序列指的是 所有一开始没有感冒的小朋友最后得感冒的顺序序列。请你返回所有感冒序列的数目。
由于答案可能很大，请你将答案对109 + 7取余后返回。
注意，感冒序列 不 包含一开始就得了感冒的小朋友的下标。

示例 1：

输入：n = 5, sick = [0,4]
输出：4
解释：一开始，下标为 1 ，2 和 3 的小朋友没有感冒。总共有 4 个可能的感冒序列：
- 一开始，下标为 1 和 3 的小朋友可以被传染，因为他们分别挨着有感冒的小朋友 0 和 4 ，令下标为 1 的小朋友先被传染。
然后，下标为 2 的小朋友挨着感冒的小朋友 1 ，下标为 3 的小朋友挨着感冒的小朋友 4 ，两位小朋友都可以被传染，令下标为 2 的小朋友被传染。
最后，下标为 3 的小朋友被传染，因为他挨着感冒的小朋友 2 和 4 ，感冒序列为 [1,2,3] 。
- 一开始，下标为 1 和 3 的小朋友可以被传染，因为他们分别挨着感冒的小朋友 0 和 4 ，令下标为 1 的小朋友先被传染。
然后，下标为 2 的小朋友挨着感冒的小朋友 1 ，下标为 3 的小朋友挨着感冒的小朋友 4 ，两位小朋友都可以被传染，令下标为 3 的小朋友被传染。
最后，下标为 2 的小朋友被传染，因为他挨着感冒的小朋友 1 和 3 ，感冒序列为  [1,3,2] 。
- 感冒序列 [3,1,2] ，被传染的顺序：[0,1,2,3,4] => [0,1,2,3,4] => [0,1,2,3,4] => [0,1,2,3,4] 。
- 感冒序列 [3,2,1] ，被传染的顺序：[0,1,2,3,4] => [0,1,2,3,4] => [0,1,2,3,4] => [0,1,2,3,4] 。

示例 2：

输入：n = 4, sick = [1]
输出：3
解释：一开始，下标为 0 ，2 和 3 的小朋友没有感冒。总共有 3 个可能的感冒序列：
- 感冒序列 [0,2,3] ，被传染的顺序：[0,1,2,3] => [0,1,2,3] => [0,1,2,3] => [0,1,2,3] 。
- 感冒序列 [2,0,3] ，被传染的顺序：[0,1,2,3] => [0,1,2,3] => [0,1,2,3] => [0,1,2,3] 。
- 感冒序列 [2,3,0] ，被传染的顺序：[0,1,2,3] => [0,1,2,3] => [0,1,2,3] => [0,1,2,3] 。

提示：

2 <= n <= 105
1 <= sick.length <= n - 1
0 <= sick[i] <= n - 1
sick按升序排列。

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

```

my_solution = Solution()

test_input = { "n": 5, "sick": [0,4] }
assert my_solution.numberOfSequence(**test_input) == 4

test_input = { "n": 4, "sick": [1] }
assert my_solution.numberOfSequence(**test_input) == 3

test_input = { "n": 2, "sick": [0] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 5, "sick": [0] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 100, "sick": [0] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 2, "sick": [1] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 5, "sick": [1] }
assert my_solution.numberOfSequence(**test_input) == 4

test_input = { "n": 5, "sick": [2] }
assert my_solution.numberOfSequence(**test_input) == 6

test_input = { "n": 5, "sick": [3] }
assert my_solution.numberOfSequence(**test_input) == 4

test_input = { "n": 5, "sick": [4] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 5, "sick": [0,1] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 3, "sick": [0,2] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 5, "sick": [0,2] }
assert my_solution.numberOfSequence(**test_input) == 3

test_input = { "n": 5, "sick": [0,3] }
assert my_solution.numberOfSequence(**test_input) == 6

test_input = { "n": 5, "sick": [1,2] }
assert my_solution.numberOfSequence(**test_input) == 3

test_input = { "n": 5, "sick": [1,3] }
assert my_solution.numberOfSequence(**test_input) == 6

test_input = { "n": 5, "sick": [1,4] }
assert my_solution.numberOfSequence(**test_input) == 6

test_input = { "n": 5, "sick": [2,3] }
assert my_solution.numberOfSequence(**test_input) == 3

test_input = { "n": 5, "sick": [2,4] }
assert my_solution.numberOfSequence(**test_input) == 3

test_input = { "n": 5, "sick": [3,4] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 5, "sick": [0,1,2] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 5, "sick": [0,1,3] }
assert my_solution.numberOfSequence(**test_input) == 2

test_input = { "n": 5, "sick": [0,1,4] }
assert my_solution.numberOfSequence(**test_input) == 2

test_input = { "n": 5, "sick": [0,2,3] }
assert my_solution.numberOfSequence(**test_input) == 2

test_input = { "n": 5, "sick": [0,2,4] }
assert my_solution.numberOfSequence(**test_input) == 2

test_input = { "n": 5, "sick": [0,3,4] }
assert my_solution.numberOfSequence(**test_input) == 2

test_input = { "n": 5, "sick": [1,2,3] }
assert my_solution.numberOfSequence(**test_input) == 2

test_input = { "n": 5, "sick": [1,2,4] }
assert my_solution.numberOfSequence(**test_input) == 2

test_input = { "n": 5, "sick": [1,3,4] }
assert my_solution.numberOfSequence(**test_input) == 2

test_input = { "n": 5, "sick": [2,3,4] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 5, "sick": [0,1,2,3] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 10, "sick": [0,1,2,3] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 5, "sick": [0,1,2,4] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 10, "sick": [0,1,2,4] }
assert my_solution.numberOfSequence(**test_input) == 6

test_input = { "n": 10, "sick": [0,1,2,5] }
assert my_solution.numberOfSequence(**test_input) == 30

test_input = { "n": 10, "sick": [0,1,2,8] }
assert my_solution.numberOfSequence(**test_input) == 96

test_input = { "n": 10, "sick": [0,1,2,9] }
assert my_solution.numberOfSequence(**test_input) == 32

test_input = { "n": 5, "sick": [0,1,3,4] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 10, "sick": [0,1,3,5] }
assert my_solution.numberOfSequence(**test_input) == 30

test_input = { "n": 10, "sick": [0,1,3,6] }
assert my_solution.numberOfSequence(**test_input) == 120

test_input = { "n": 10, "sick": [0,1,3,7] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,1,3,8] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,1,4,5] }
assert my_solution.numberOfSequence(**test_input) == 30

test_input = { "n": 10, "sick": [0,1,4,6] }
assert my_solution.numberOfSequence(**test_input) == 120

test_input = { "n": 10, "sick": [0,1,4,7] }
assert my_solution.numberOfSequence(**test_input) == 360

test_input = { "n": 10, "sick": [0,1,4,8] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,1,4,9] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,1,5,6] }
assert my_solution.numberOfSequence(**test_input) == 80

test_input = { "n": 10, "sick": [0,1,5,7] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,1,5,8] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,1,5,9] }
assert my_solution.numberOfSequence(**test_input) == 320

test_input = { "n": 10, "sick": [0,1,6,7] }
assert my_solution.numberOfSequence(**test_input) == 120

test_input = { "n": 10, "sick": [0,1,6,8] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,1,6,9] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,1,7,8] }
assert my_solution.numberOfSequence(**test_input) == 96

test_input = { "n": 10, "sick": [0,1,7,9] }
assert my_solution.numberOfSequence(**test_input) == 96

test_input = { "n": 10, "sick": [0,1,8,9] }
assert my_solution.numberOfSequence(**test_input) == 32

test_input = { "n": 5, "sick": [0,2,3,4] }
assert my_solution.numberOfSequence(**test_input) == 1

test_input = { "n": 10, "sick": [0,2,3,4] }
assert my_solution.numberOfSequence(**test_input) == 6

test_input = { "n": 10, "sick": [0,2,3,5] }
assert my_solution.numberOfSequence(**test_input) == 30

test_input = { "n": 10, "sick": [0,2,3,6] }
assert my_solution.numberOfSequence(**test_input) == 120

test_input = { "n": 10, "sick": [0,2,3,7] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,2,3,8] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,2,3,9] }
assert my_solution.numberOfSequence(**test_input) == 96

test_input = { "n": 10, "sick": [0,2,4,5] }
assert my_solution.numberOfSequence(**test_input) == 30

test_input = { "n": 10, "sick": [0,2,4,6] }
assert my_solution.numberOfSequence(**test_input) == 120

test_input = { "n": 10, "sick": [0,2,4,7] }
assert my_solution.numberOfSequence(**test_input) == 360

test_input = { "n": 10, "sick": [0,2,4,8] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,2,4,9] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,2,5,6] }
assert my_solution.numberOfSequence(**test_input) == 120

test_input = { "n": 10, "sick": [0,2,5,7] }
assert my_solution.numberOfSequence(**test_input) == 360

test_input = { "n": 10, "sick": [0,2,5,8] }
assert my_solution.numberOfSequence(**test_input) == 720

test_input = { "n": 10, "sick": [0,2,5,9] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,2,6,7] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,2,6,8] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,2,7,8] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,2,7,9] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,2,8,9] }
assert my_solution.numberOfSequence(**test_input) == 96

test_input = { "n": 10, "sick": [0,3,4,5] }
assert my_solution.numberOfSequence(**test_input) == 30

test_input = { "n": 10, "sick": [0,3,4,7] }
assert my_solution.numberOfSequence(**test_input) == 360

test_input = { "n": 10, "sick": [0,3,4,8] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,3,4,9] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,3,5,6] }
assert my_solution.numberOfSequence(**test_input) == 120

test_input = { "n": 10, "sick": [0,3,5,7] }
assert my_solution.numberOfSequence(**test_input) == 360

test_input = { "n": 10, "sick": [0,3,6,7] }
assert my_solution.numberOfSequence(**test_input) == 360

test_input = { "n": 10, "sick": [0,3,6,8] }
assert my_solution.numberOfSequence(**test_input) == 720

test_input = { "n": 10, "sick": [0,3,6,9] }
assert my_solution.numberOfSequence(**test_input) == 720

test_input = { "n": 10, "sick": [0,3,7,8] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,3,7,9] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,3,8,9] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,4,5,6] }
assert my_solution.numberOfSequence(**test_input) == 80

test_input = { "n": 10, "sick": [0,4,5,7] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,4,5,9] }
assert my_solution.numberOfSequence(**test_input) == 320

test_input = { "n": 10, "sick": [0,4,6,7] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,4,6,8] }
assert my_solution.numberOfSequence(**test_input) == 480

test_input = { "n": 10, "sick": [0,4,8,9] }
assert my_solution.numberOfSequence(**test_input) == 320

test_input = { "n": 10, "sick": [0,5,6,7] }
assert my_solution.numberOfSequence(**test_input) == 120

test_input = { "n": 10, "sick": [0,5,6,9] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,5,7,8] }
assert my_solution.numberOfSequence(**test_input) == 240

test_input = { "n": 10, "sick": [0,5,7,9] }
assert my_solution.numberOfSequence(**test_input) == 240


matrix-similarity-after-cyclic-shifts

Matrix Similarity After Cyclic Shifts

Prompt:
"""
给你一个下标从 0 开始且大小为 m x n 的整数矩阵 mat 和一个整数 k 。请你将矩阵中的 奇数 行循环 右 移 k 次，偶数 行循环 左 移 k 次。
如果初始矩阵和最终矩阵完全相同，则返回 true ，否则返回 false 。

示例 1：

输入：mat = [[1,2,1,2],[5,5,5,5],[6,3,6,3]], k = 2
输出：true
解释：

初始矩阵如图一所示。
图二表示对奇数行右移一次且对偶数行左移一次后的矩阵状态。
图三是经过两次循环移位后的最终矩阵状态，与初始矩阵相同。
因此，返回 true 。

示例 2：

输入：mat = [[2,2],[2,2]], k = 3
输出：true
解释：由于矩阵中的所有值都相等，即使进行循环移位，矩阵仍然保持不变。因此，返回 true 。

示例 3：

输入：mat = [[1,2]], k = 1
输出：false
解释：循环移位一次后，mat = [[2,1]]，与初始矩阵不相等。因此，返回 false 。

提示：

1 <= mat.length <= 25
1 <= mat[i].length <= 25
1 <= mat[i][j] <= 25
1 <= k <= 50
"""
class Solution:
    def areSimilar(self, mat: List[List[int]], k: int) -> bool:

给你一个下标从 0 开始且大小为 m x n 的整数矩阵 mat 和一个整数 k 。请你将矩阵中的 奇数 行循环 右 移 k 次，偶数 行循环 左 移 k 次。
如果初始矩阵和最终矩阵完全相同，则返回 true ，否则返回 false 。

示例 1：

输入：mat = [[1,2,1,2],[5,5,5,5],[6,3,6,3]], k = 2
输出：true
解释：

初始矩阵如图一所示。
图二表示对奇数行右移一次且对偶数行左移一次后的矩阵状态。
图三是经过两次循环移位后的最终矩阵状态，与初始矩阵相同。
因此，返回 true 。

示例 2：

输入：mat = [[2,2],[2,2]], k = 3
输出：true
解释：由于矩阵中的所有值都相等，即使进行循环移位，矩阵仍然保持不变。因此，返回 true 。

示例 3：

输入：mat = [[1,2]], k = 1
输出：false
解释：循环移位一次后，mat = [[2,1]]，与初始矩阵不相等。因此，返回 false 。

提示：

1 <= mat.length <= 25
1 <= mat[i].length <= 25
1 <= mat[i][j] <= 25
1 <= k <= 50

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

```


count-beautiful-substrings-i

Count Beautiful Substrings I

Prompt:
"""
给你一个字符串 s 和一个正整数 k 。
用 vowels 和 consonants 分别表示字符串中元音字母和辅音字母的数量。
如果某个字符串满足以下条件，则称其为 美丽字符串 ：

vowels == consonants，即元音字母和辅音字母的数量相等。
(vowels * consonants) % k == 0，即元音字母和辅音字母的数量的乘积能被 k 整除。

返回字符串 s 中 非空美丽子字符串 的数量。
子字符串是字符串中的一个连续字符序列。
英语中的 元音字母 为 'a'、'e'、'i'、'o' 和 'u' 。
英语中的 辅音字母 为除了元音字母之外的所有字母。

示例 1：

输入：s = "baeyh", k = 2
输出：2
解释：字符串 s 中有 2 个美丽子字符串。
- 子字符串 "baeyh"，vowels = 2（["a","e"]），consonants = 2（["y","h"]）。
可以看出字符串 "aeyh" 是美丽字符串，因为 vowels == consonants 且 vowels * consonants % k == 0 。
- 子字符串 "baeyh"，vowels = 2（["a","e"]），consonants = 2（["b","y"]）。
可以看出字符串 "baey" 是美丽字符串，因为 vowels == consonants 且 vowels * consonants % k == 0 。
可以证明字符串 s 中只有 2 个美丽子字符串。

示例 2：

输入：s = "abba", k = 1
输出：3
解释：字符串 s 中有 3 个美丽子字符串。
- 子字符串 "abba"，vowels = 1（["a"]），consonants = 1（["b"]）。
- 子字符串 "abba"，vowels = 1（["a"]），consonants = 1（["b"]）。
- 子字符串 "abba"，vowels = 2（["a","a"]），consonants = 2（["b","b"]）。
可以证明字符串 s 中只有 3 个美丽子字符串。

示例 3：

输入：s = "bcdf", k = 1
输出：0
解释：字符串 s 中没有美丽子字符串。

提示：

1 <= s.length <= 1000
1 <= k <= 1000
s 仅由小写英文字母组成。
"""
class Solution:
    def beautifulSubstrings(self, s: str, k: int) -> int:

给你一个字符串 s 和一个正整数 k 。
用 vowels 和 consonants 分别表示字符串中元音字母和辅音字母的数量。
如果某个字符串满足以下条件，则称其为 美丽字符串 ：

vowels == consonants，即元音字母和辅音字母的数量相等。
(vowels * consonants) % k == 0，即元音字母和辅音字母的数量的乘积能被 k 整除。

返回字符串 s 中 非空美丽子字符串 的数量。
子字符串是字符串中的一个连续字符序列。
英语中的 元音字母 为 'a'、'e'、'i'、'o' 和 'u' 。
英语中的 辅音字母 为除了元音字母之外的所有字母。

示例 1：

输入：s = "baeyh", k = 2
输出：2
解释：字符串 s 中有 2 个美丽子字符串。
- 子字符串 "baeyh"，vowels = 2（["a","e"]），consonants = 2（["y","h"]）。
可以看出字符串 "aeyh" 是美丽字符串，因为 vowels == consonants 且 vowels * consonants % k == 0 。
- 子字符串 "baeyh"，vowels = 2（["a","e"]），consonants = 2（["b","y"]）。
可以看出字符串 "baey" 是美丽字符串，因为 vowels == consonants 且 vowels * consonants % k == 0 。
可以证明字符串 s 中只有 2 个美丽子字符串。

示例 2：

输入：s = "abba", k = 1
输出：3
解释：字符串 s 中有 3 个美丽子字符串。
- 子字符串 "abba"，vowels = 1（["a"]），consonants = 1（["b"]）。
- 子字符串 "abba"，vowels = 1（["a"]），consonants = 1（["b"]）。
- 子字符串 "abba"，vowels = 2（["a","a"]），consonants = 2（["b","b"]）。
可以证明字符串 s 中只有 3 个美丽子字符串。

示例 3：

输入：s = "bcdf", k = 1
输出：0
解释：字符串 s 中没有美丽子字符串。

提示：

1 <= s.length <= 1000
1 <= k <= 1000
s 仅由小写英文字母组成。

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

```

my_solution = Solution()

test_input = { "s": "baeyh", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "abba", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "bcdf", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "ihroyeeb", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "uzuxpzou", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "ouuoeqd", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "eeebjoxxujuaeoqibd", "k": 8 }
assert my_solution.beautifulSubstrings(**test_input) == 4

test_input = { "s": "ilougekqlovegioemdvu", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 21

test_input = { "s": "tqaewreikaztwpfwnef", "k": 8 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "oykiuhsafgfjumnzb", "k": 7 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "ifvsa", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "svzauyuevujektj", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "urahjig", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "ime", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "oacghieut", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "aoluu", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "ioaoiciiuoziout", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 5

test_input = { "s": "ouafupsuhid", "k": 6 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "ox", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "tlaiwoauazutusiaaui", "k": 10 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "caepeym", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "apyxvceue", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "imkqbb", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "caaz", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "pyicoy", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 6

test_input = { "s": "uopmyrsntjhiroikup", "k": 8 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "aujfxqxcj", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "eeizejuoxeumz", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 6

test_input = { "s": "uuouuaifnboeiulttio", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 10

test_input = { "s": "woozzxd", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "pulorolqcvhafexui", "k": 9 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "hmuaewojioizoguvoaje", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 4

test_input = { "s": "b", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "aiejouohnqnketinvat", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 6

test_input = { "s": "mjiogpri", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "movbyaeouil", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "puureouausxmitvav", "k": 6 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "op", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "iuhoezpooxcohtlapolo", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 39

test_input = { "s": "cioi", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "pueutaoyaxk", "k": 6 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "iiuresacruaaan", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "agntyaazvpejidwaph", "k": 8 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "wiybolyniexiibou", "k": 6 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "coiyakadxi", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 8

test_input = { "s": "oraajoeruiakixj", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "jeayap", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 7

test_input = { "s": "iu", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "awozoy", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "fheabmlsyeeeuoeogyz", "k": 9 }
assert my_solution.beautifulSubstrings(**test_input) == 5

test_input = { "s": "eaizneuxi", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 10

test_input = { "s": "uurqufaucsuoqljh", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 14

test_input = { "s": "jrtept", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "olgioxooiejooosaed", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "uizoy", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "lswabfiujjhexzos", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 5

test_input = { "s": "iuu", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "qeaxut", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 7

test_input = { "s": "aojiau", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "oaiaaaargkonlcsoaygf", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "zoowrawkm", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "uqiwuoevkfhkkua", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 6

test_input = { "s": "kavuaaeodvaxicm", "k": 6 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "qpxeceq", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 6

test_input = { "s": "iaabaofuodcbek", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "eel", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "ikeuhe", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 5

test_input = { "s": "lueikvo", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "oauau", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "qzoieeotieeakqraeao", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 4

test_input = { "s": "ehaascocsdmgekni", "k": 9 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "euqeklniykiji", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "vaeiiioidiioxhduu", "k": 7 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "aa", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "chaua", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "edfrglfr", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "dqbe", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "ghooirorxge", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 6

test_input = { "s": "fodartekaonq", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 9

test_input = { "s": "feeanzkjpfehzeuni", "k": 6 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "ignoouesduu", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 6

test_input = { "s": "yif", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "gondfjaeeuhbuuasgip", "k": 10 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "djooomsffoonelyeode", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 14

test_input = { "s": "pgaimei", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 2

test_input = { "s": "naipqentonee", "k": 4 }
assert my_solution.beautifulSubstrings(**test_input) == 8

test_input = { "s": "bouov", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "lcuhoypz", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "g", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "qc", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "mhznea", "k": 2 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "uxvjixdujgyfauo", "k": 8 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "iyjkuox", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "xbjfoayfpafatnuyord", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "nvoede", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 1

test_input = { "s": "usnuaxpaktrweatruu", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "euojmsora", "k": 1 }
assert my_solution.beautifulSubstrings(**test_input) == 10

test_input = { "s": "iapgoi", "k": 3 }
assert my_solution.beautifulSubstrings(**test_input) == 0

test_input = { "s": "uafuimcpxyeoixgbyeio", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 3

test_input = { "s": "weuaatpu", "k": 5 }
assert my_solution.beautifulSubstrings(**test_input) == 0