count-the-number-of-incremovable-subarrays-ii

Count the Number of Incremovable Subarrays II

Prompt:
"""
给你一个下标从 0开始的 正整数数组nums。
如果 nums的一个子数组满足：移除这个子数组后剩余元素 严格递增，那么我们称这个子数组为 移除递增子数组。比方说，[5, 3, 4, 6, 7]中的 [3, 4]是一个移除递增子数组，因为移除该子数组后，[5, 3, 4, 6, 7]变为[5, 6, 7]，是严格递增的。
请你返回 nums中 移除递增子数组的总数目。
注意，剩余元素为空的数组也视为是递增的。
子数组 指的是一个数组中一段连续的元素序列。

示例 1：

输入：nums = [1,2,3,4]
输出：10
解释：10 个移除递增子数组分别为：[1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4] 和 [1,2,3,4]。移除任意一个子数组后，剩余元素都是递增的。注意，空数组不是移除递增子数组。

示例 2：

输入：nums = [6,5,7,8]
输出：7
解释：7个移除递增子数组分别为：[5], [6], [5,7], [6,5], [5,7,8], [6,5,7] 和 [6,5,7,8] 。
nums 中只有这 7 个移除递增子数组。

示例 3：

输入：nums = [8,7,6,6]
输出：3
解释：3 个移除递增子数组分别为：[8,7,6], [7,6,6] 和 [8,7,6,6] 。注意 [8,7] 不是移除递增子数组因为移除 [8,7] 后 nums 变为 [6,6] ，它不是严格递增的。

提示：

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

给你一个下标从 0开始的 正整数数组nums。
如果 nums的一个子数组满足：移除这个子数组后剩余元素 严格递增，那么我们称这个子数组为 移除递增子数组。比方说，[5, 3, 4, 6, 7]中的 [3, 4]是一个移除递增子数组，因为移除该子数组后，[5, 3, 4, 6, 7]变为[5, 6, 7]，是严格递增的。
请你返回 nums中 移除递增子数组的总数目。
注意，剩余元素为空的数组也视为是递增的。
子数组 指的是一个数组中一段连续的元素序列。

示例 1：

输入：nums = [1,2,3,4]
输出：10
解释：10 个移除递增子数组分别为：[1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4] 和 [1,2,3,4]。移除任意一个子数组后，剩余元素都是递增的。注意，空数组不是移除递增子数组。

示例 2：

输入：nums = [6,5,7,8]
输出：7
解释：7个移除递增子数组分别为：[5], [6], [5,7], [6,5], [5,7,8], [6,5,7] 和 [6,5,7,8] 。
nums 中只有这 7 个移除递增子数组。

示例 3：

输入：nums = [8,7,6,6]
输出：3
解释：3 个移除递增子数组分别为：[8,7,6], [7,6,6] 和 [8,7,6,6] 。注意 [8,7] 不是移除递增子数组因为移除 [8,7] 后 nums 变为 [6,6] ，它不是严格递增的。

提示：

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

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

```

my_solution = Solution()

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

test_input = { "nums": [6,5,7,8] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [8,7,6,6] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [8,10] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

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

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

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

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

test_input = { "nums": [9,3,8] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

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

test_input = { "nums": [1,9,6,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [4,8,5,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

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

test_input = { "nums": [10,2,5,7] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

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

test_input = { "nums": [1,5,9,5,7] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

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

test_input = { "nums": [8,5,5,3,10] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

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

test_input = { "nums": [11,50,14,33,45,38,33,19,28,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

test_input = { "nums": [25,9,28,31,38,15,31,44,46,49] }
assert my_solution.incremovableSubarrayCount(**test_input) == 11

test_input = { "nums": [25,26,49,31,40,47,30,29,32,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 13

test_input = { "nums": [25,39,29,30,40,28,30,39,30,42] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [25,41,31,38,30,38,37,41,36,32] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [25,45,49,28,47,44,42,34,28,25] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [25,46,48,41,29,47,32,34,41,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [25,47,25,35,48,49,27,37,36,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [26,26,50,38,30,38,31,26,39,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [26,32,41,38,45,32,31,27,48,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [26,45,44,26,33,35,34,36,44,38] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [26,49,42,26,37,41,31,36,45,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [27,39,32,30,38,41,28,26,49,49] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [27,43,36,37,33,46,48,35,49,49] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [28,17,12,21,21,49,31,30,40,13] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [28,30,39,31,33,41,47,36,43,46] }
assert my_solution.incremovableSubarrayCount(**test_input) == 15

test_input = { "nums": [29,27,32,38,26,38,39,30,41,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [29,31,48,28,27,38,32,28,30,44] }
assert my_solution.incremovableSubarrayCount(**test_input) == 10

test_input = { "nums": [29,34,44,27,45,31,37,32,50,26] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [29,38,36,42,31,38,27,48,42,28] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [29,46,34,47,46,41,29,29,38,39] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [29,49,32,35,38,37,27,25,50,46] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [30,27,38,33,28,48,41,30,25,50] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [30,29,31,44,31,25,50,35,35,47] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [30,30,46,35,31,41,30,37,37,33] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [30,41,28,45,35,41,47,32,29,33] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [30,45,44,27,43,40,28,34,39,40] }
assert my_solution.incremovableSubarrayCount(**test_input) == 10

test_input = { "nums": [30,49,34,26,50,50,48,49,39,26] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [31,34,25,43,38,34,29,50,27,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [31,35,39,38,41,47,26,43,47,46] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [31,37,29,41,32,46,25,28,30,29] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [31,38,31,47,25,25,36,29,43,28] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [31,41,25,37,43,29,30,26,30,46] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [31,42,40,36,39,28,43,29,35,50] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

test_input = { "nums": [32,29,13,39,34,47,38,15,10,5] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [32,35,32,50,32,26,29,49,40,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

test_input = { "nums": [32,37,35,26,45,44,47,29,31,28] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [32,43,44,44,36,41,31,33,41,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 11

test_input = { "nums": [32,50,50,46,32,30,32,32,31,39] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [33,27,34,46,42,35,36,49,25,40] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [33,28,35,32,36,38,33,47,36,35] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [33,31,36,38,39,46,42,41,27,33] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [33,45,25,48,45,42,35,38,47,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [33,46,38,37,42,48,31,43,38,29] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [33,48,50,48,46,33,34,26,32,33] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [34,25,38,41,31,46,40,46,39,30] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [34,38,35,28,30,37,35,25,48,28] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [34,47,26,48,30,25,26,43,44,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [35,22,35,6,20,47,3,29,45,30] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [35,25,29,40,32,29,35,39,39,32] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [35,26,39,41,26,44,36,26,46,50] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [35,27,29,45,29,30,48,42,37,50] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [35,31,27,45,39,46,47,49,26,27] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [35,39,36,30,32,48,34,25,37,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

test_input = { "nums": [36,26,44,32,36,29,44,28,48,30] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [36,28,28,45,40,40,32,48,34,48] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [36,28,34,49,48,36,50,25,43,40] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [36,30,47,32,32,35,41,49,41,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [36,31,45,34,47,48,49,31,34,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [37,33,50,48,25,37,29,49,46,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [37,35,29,27,39,38,49,48,27,37] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [37,40,42,41,30,40,46,44,47,27] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [37,43,49,40,30,46,31,44,47,25] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [37,45,49,26,32,45,33,40,35,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [37,50,42,50,40,26,34,25,28,44] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [38,28,25,31,28,44,35,26,33,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [38,30,36,50,36,40,41,25,43,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4


find-number-of-coins-to-place-in-tree-nodes

Find Number of Coins to Place in Tree Nodes

Prompt:
"""
给你一棵n个节点的无向树，节点编号为0到n - 1，树的根节点在节点0处。同时给你一个长度为 n - 1的二维整数数组edges，其中edges[i] = [ai, bi]表示树中节点ai 和bi之间有一条边。
给你一个长度为 n下标从 0开始的整数数组cost，其中cost[i]是第 i个节点的 开销。
你需要在树中每个节点都放置金币，在节点 i处的金币数目计算方法如下：

如果节点 i对应的子树中的节点数目小于3，那么放1个金币。
否则，计算节点 i 对应的子树内 3 个不同节点的开销乘积的 最大值 ，并在节点 i 处放置对应数目的金币。如果最大乘积是 负数，那么放置 0个金币。

请你返回一个长度为 n的数组coin，coin[i]是节点i处的金币数目。

示例 1：

输入：edges = [[0,1],[0,2],[0,3],[0,4],[0,5]], cost = [1,2,3,4,5,6]
输出：[120,1,1,1,1,1]
解释：在节点 0 处放置 6 * 5 * 4 = 120 个金币。所有其他节点都是叶子节点，子树中只有 1 个节点，所以其他每个节点都放 1 个金币。

示例 2：

输入：edges = [[0,1],[0,2],[1,3],[1,4],[1,5],[2,6],[2,7],[2,8]], cost = [1,4,2,3,5,7,8,-4,2]
输出：[280,140,32,1,1,1,1,1,1]
解释：每个节点放置的金币数分别为：
- 节点 0 处放置 8 * 7 * 5 = 280 个金币。
- 节点 1 处放置 7 * 5 * 4 = 140 个金币。
- 节点 2 处放置 8 * 2 * 2 = 32 个金币。
- 其他节点都是叶子节点，子树内节点数目为 1 ，所以其他每个节点都放 1 个金币。

示例 3：

输入：edges = [[0,1],[0,2]], cost = [1,2,-2]
输出：[0,1,1]
解释：节点 1 和 2 都是叶子节点，子树内节点数目为 1 ，各放置 1 个金币。节点 0 处唯一的开销乘积是 2 * 1 * -2 = -4 。所以在节点 0 处放置 0 个金币。

提示：

2 <= n <= 2 * 104
edges.length == n - 1
edges[i].length == 2
0 <= ai, bi < n
cost.length == n
1 <= |cost[i]| <= 104
edges一定是一棵合法的树。
"""
class Solution:
    def placedCoins(self, edges: List[List[int]], cost: List[int]) -> List[int]:

给你一棵n个节点的无向树，节点编号为0到n - 1，树的根节点在节点0处。同时给你一个长度为 n - 1的二维整数数组edges，其中edges[i] = [ai, bi]表示树中节点ai 和bi之间有一条边。
给你一个长度为 n下标从 0开始的整数数组cost，其中cost[i]是第 i个节点的 开销。
你需要在树中每个节点都放置金币，在节点 i处的金币数目计算方法如下：

如果节点 i对应的子树中的节点数目小于3，那么放1个金币。
否则，计算节点 i 对应的子树内 3 个不同节点的开销乘积的 最大值 ，并在节点 i 处放置对应数目的金币。如果最大乘积是 负数，那么放置 0个金币。

请你返回一个长度为 n的数组coin，coin[i]是节点i处的金币数目。

示例 1：

输入：edges = [[0,1],[0,2],[0,3],[0,4],[0,5]], cost = [1,2,3,4,5,6]
输出：[120,1,1,1,1,1]
解释：在节点 0 处放置 6 * 5 * 4 = 120 个金币。所有其他节点都是叶子节点，子树中只有 1 个节点，所以其他每个节点都放 1 个金币。

示例 2：

输入：edges = [[0,1],[0,2],[1,3],[1,4],[1,5],[2,6],[2,7],[2,8]], cost = [1,4,2,3,5,7,8,-4,2]
输出：[280,140,32,1,1,1,1,1,1]
解释：每个节点放置的金币数分别为：
- 节点 0 处放置 8 * 7 * 5 = 280 个金币。
- 节点 1 处放置 7 * 5 * 4 = 140 个金币。
- 节点 2 处放置 8 * 2 * 2 = 32 个金币。
- 其他节点都是叶子节点，子树内节点数目为 1 ，所以其他每个节点都放 1 个金币。

示例 3：

输入：edges = [[0,1],[0,2]], cost = [1,2,-2]
输出：[0,1,1]
解释：节点 1 和 2 都是叶子节点，子树内节点数目为 1 ，各放置 1 个金币。节点 0 处唯一的开销乘积是 2 * 1 * -2 = -4 。所以在节点 0 处放置 0 个金币。

提示：

2 <= n <= 2 * 104
edges.length == n - 1
edges[i].length == 2
0 <= ai, bi < n
cost.length == n
1 <= |cost[i]| <= 104
edges一定是一棵合法的树。

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

```


find-missing-and-repeated-values

Find Missing and Repeated Values

Prompt:
"""
给你一个下标从 0 开始的二维整数矩阵 grid，大小为 n * n ，其中的值在 [1, n2] 范围内。除了 a 出现 两次，b 缺失 之外，每个整数都 恰好出现一次 。
任务是找出重复的数字a 和缺失的数字 b 。
返回一个下标从 0 开始、长度为 2 的整数数组 ans ，其中 ans[0] 等于 a ，ans[1] 等于 b 。

示例 1：

输入：grid = [[1,3],[2,2]]
输出：[2,4]
解释：数字 2 重复，数字 4 缺失，所以答案是 [2,4] 。

示例 2：

输入：grid = [[9,1,7],[8,9,2],[3,4,6]]
输出：[9,5]
解释：数字 9 重复，数字 5 缺失，所以答案是 [9,5] 。

提示：

2 <= n == grid.length == grid[i].length <= 50
1 <= grid[i][j] <= n * n
对于所有满足1 <= x <= n * n 的 x ，恰好存在一个 x 与矩阵中的任何成员都不相等。
对于所有满足1 <= x <= n * n 的 x ，恰好存在一个 x 与矩阵中的两个成员相等。
除上述的两个之外，对于所有满足1 <= x <= n * n 的 x ，都恰好存在一对 i, j 满足 0 <= i, j <= n - 1 且 grid[i][j] == x 。
"""
class Solution:
    def findMissingAndRepeatedValues(self, grid: List[List[int]]) -> List[int]:

给你一个下标从 0 开始的二维整数矩阵 grid，大小为 n * n ，其中的值在 [1, n2] 范围内。除了 a 出现 两次，b 缺失 之外，每个整数都 恰好出现一次 。
任务是找出重复的数字a 和缺失的数字 b 。
返回一个下标从 0 开始、长度为 2 的整数数组 ans ，其中 ans[0] 等于 a ，ans[1] 等于 b 。

示例 1：

输入：grid = [[1,3],[2,2]]
输出：[2,4]
解释：数字 2 重复，数字 4 缺失，所以答案是 [2,4] 。

示例 2：

输入：grid = [[9,1,7],[8,9,2],[3,4,6]]
输出：[9,5]
解释：数字 9 重复，数字 5 缺失，所以答案是 [9,5] 。

提示：

2 <= n == grid.length == grid[i].length <= 50
1 <= grid[i][j] <= n * n
对于所有满足1 <= x <= n * n 的 x ，恰好存在一个 x 与矩阵中的任何成员都不相等。
对于所有满足1 <= x <= n * n 的 x ，恰好存在一个 x 与矩阵中的两个成员相等。
除上述的两个之外，对于所有满足1 <= x <= n * n 的 x ，都恰好存在一对 i, j 满足 0 <= i, j <= n - 1 且 grid[i][j] == x 。

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

```

my_solution = Solution()

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

test_input = { "grid": [[9,1,7],[8,9,2],[3,4,6]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [9,5]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "grid": [[1,3,4],[9,7,5],[8,2,3]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [3,6]

test_input = { "grid": [[1,5,2],[8,4,3],[7,8,6]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [8,9]

test_input = { "grid": [[1,5,8],[2,7,3],[6,1,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [1,9]

test_input = { "grid": [[1,6,1],[4,3,7],[5,2,8]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [1,9]

test_input = { "grid": [[1,6,4],[9,7,5],[7,8,2]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,3]

test_input = { "grid": [[1,6,7],[3,6,8],[9,5,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [6,2]

test_input = { "grid": [[1,7,4],[8,6,2],[8,3,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [8,9]

test_input = { "grid": [[1,7,8],[4,5,6],[3,9,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [9,2]

test_input = { "grid": [[1,8,4],[9,2,7],[6,3,8]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [8,5]

test_input = { "grid": [[1,8,5],[4,3,2],[7,9,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [4,6]

test_input = { "grid": [[1,9,3],[2,7,8],[2,4,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,6]

test_input = { "grid": [[1,9,7],[8,4,2],[6,3,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [9,5]

test_input = { "grid": [[2,1,3],[2,9,4],[6,8,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,7]

test_input = { "grid": [[2,2,4],[7,5,3],[1,6,8]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,9]

test_input = { "grid": [[2,3,9],[5,6,4],[2,8,7]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,1]

test_input = { "grid": [[2,4,6],[4,8,9],[7,3,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [4,1]

test_input = { "grid": [[2,5,5],[4,8,7],[9,3,6]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [5,1]

test_input = { "grid": [[2,6,4],[6,9,5],[3,7,8]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [6,1]

test_input = { "grid": [[2,6,9],[1,7,9],[4,8,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [9,3]

test_input = { "grid": [[2,7,1],[8,6,2],[9,3,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,5]

test_input = { "grid": [[2,7,5],[7,6,4],[1,3,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,8]

test_input = { "grid": [[2,7,9],[6,8,1],[4,1,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [1,3]

test_input = { "grid": [[2,9,7],[8,5,1],[6,7,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,3]

test_input = { "grid": [[3,4,5],[8,2,4],[6,1,7]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [4,9]

test_input = { "grid": [[3,5,7],[8,6,9],[1,5,2]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [5,4]

test_input = { "grid": [[3,6,1],[5,9,2],[1,7,8]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [1,4]

test_input = { "grid": [[3,9,4],[3,6,1],[5,7,2]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [3,8]

test_input = { "grid": [[4,2,6],[3,5,8],[3,1,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [3,7]

test_input = { "grid": [[4,3,2],[6,9,9],[8,7,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [9,1]

test_input = { "grid": [[4,6,5],[3,5,7],[2,8,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [5,1]

test_input = { "grid": [[4,8,7],[4,6,9],[3,2,1]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [4,5]

test_input = { "grid": [[4,9,6],[2,5,8],[3,7,7]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,1]

test_input = { "grid": [[5,3,6],[1,4,2],[9,8,2]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,7]

test_input = { "grid": [[5,6,9],[3,7,8],[2,2,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,1]

test_input = { "grid": [[5,7,8],[1,3,2],[7,6,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,4]

test_input = { "grid": [[6,1,3],[2,4,2],[8,9,7]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,5]

test_input = { "grid": [[6,4,2],[3,7,8],[5,6,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [6,1]

test_input = { "grid": [[6,4,5],[7,9,3],[1,2,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [9,8]

test_input = { "grid": [[6,4,8],[8,1,2],[9,3,7]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [8,5]

test_input = { "grid": [[6,9,3],[8,9,7],[5,4,2]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [9,1]

test_input = { "grid": [[7,2,1],[6,5,3],[2,9,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,8]

test_input = { "grid": [[7,2,4],[5,8,7],[9,3,1]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,6]

test_input = { "grid": [[7,3,1],[8,9,2],[4,5,2]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [2,6]

test_input = { "grid": [[7,4,2],[9,1,9],[8,3,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [9,6]

test_input = { "grid": [[7,4,8],[1,1,3],[2,6,9]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [1,5]

test_input = { "grid": [[7,5,3],[4,6,3],[9,2,8]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [3,1]

test_input = { "grid": [[7,5,7],[3,1,6],[8,9,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,2]

test_input = { "grid": [[8,2,6],[1,8,9],[4,5,3]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [8,7]

test_input = { "grid": [[8,2,7],[3,5,1],[9,6,3]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [3,4]

test_input = { "grid": [[8,6,3],[1,9,5],[5,4,7]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [5,2]

test_input = { "grid": [[8,6,5],[3,9,1],[8,7,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [8,2]

test_input = { "grid": [[8,9,6],[6,1,3],[2,7,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [6,4]

test_input = { "grid": [[8,9,6],[7,4,2],[7,1,5]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,3]

test_input = { "grid": [[9,2,3],[7,6,4],[5,8,8]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [8,1]

test_input = { "grid": [[9,2,7],[3,8,7],[1,5,4]] }
assert my_solution.findMissingAndRepeatedValues(**test_input) == [7,6]


divide-array-into-arrays-with-max-difference

Divide Array Into Arrays With Max Difference

Prompt:
"""
给你一个长度为 n 的整数数组 nums，以及一个正整数 k 。
将这个数组划分为一个或多个长度为 3 的子数组，并满足以下条件：

nums 中的 每个 元素都必须 恰好 存在于某个子数组中。
子数组中 任意 两个元素的差必须小于或等于 k 。

返回一个 二维数组 ，包含所有的子数组。如果不可能满足条件，就返回一个空数组。如果有多个答案，返回 任意一个 即可。

示例 1：

输入：nums = [1,3,4,8,7,9,3,5,1], k = 2
输出：[[1,1,3],[3,4,5],[7,8,9]]
解释：可以将数组划分为以下子数组：[1,1,3]，[3,4,5] 和 [7,8,9] 。
每个子数组中任意两个元素的差都小于或等于 2 。
注意，元素的顺序并不重要。

示例 2：

输入：nums = [1,3,3,2,7,3], k = 3
输出：[]
解释：无法划分数组满足所有条件。

提示：

n == nums.length
1 <= n <= 105
n 是 3 的倍数
1 <= nums[i] <= 105
1 <= k <= 105
"""
class Solution:
    def divideArray(self, nums: List[int], k: int) -> List[List[int]]:

给你一个长度为 n 的整数数组 nums，以及一个正整数 k 。
将这个数组划分为一个或多个长度为 3 的子数组，并满足以下条件：

nums 中的 每个 元素都必须 恰好 存在于某个子数组中。
子数组中 任意 两个元素的差必须小于或等于 k 。

返回一个 二维数组 ，包含所有的子数组。如果不可能满足条件，就返回一个空数组。如果有多个答案，返回 任意一个 即可。

示例 1：

输入：nums = [1,3,4,8,7,9,3,5,1], k = 2
输出：[[1,1,3],[3,4,5],[7,8,9]]
解释：可以将数组划分为以下子数组：[1,1,3]，[3,4,5] 和 [7,8,9] 。
每个子数组中任意两个元素的差都小于或等于 2 。
注意，元素的顺序并不重要。

示例 2：

输入：nums = [1,3,3,2,7,3], k = 3
输出：[]
解释：无法划分数组满足所有条件。

提示：

n == nums.length
1 <= n <= 105
n 是 3 的倍数
1 <= nums[i] <= 105
1 <= k <= 105

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

```


minimum-cost-to-make-array-equalindromic

Minimum Cost to Make Array Equalindromic

Prompt:
"""
给你一个长度为 n下标从 0开始的整数数组nums。
你可以对 nums执行特殊操作 任意次（也可以 0次）。每一次特殊操作中，你需要 按顺序执行以下步骤：

从范围[0, n - 1]里选择一个下标 i和一个 正整数x。
将|nums[i] - x|添加到总代价里。
将 nums[i]变为x。

如果一个正整数正着读和反着读都相同，那么我们称这个数是回文数。比方说，121，2552 和65756都是回文数，但是24，46，235都不是回文数。
如果一个数组中的所有元素都等于一个整数y，且y是一个小于109的回文数，那么我们称这个数组是一个 等数数组。
请你返回一个整数，表示执行任意次特殊操作后使 nums成为 等数数组的 最小总代价。

示例 1：

输入：nums = [1,2,3,4,5]
输出：6
解释：我们可以将数组中所有元素变为回文数 3 得到等数数组，数组变成 [3,3,3,3,3] 需要执行 4 次特殊操作，代价为 |1 - 3| + |2 - 3| + |4 - 3| + |5 - 3| = 6 。
将所有元素变为其他回文数的总代价都大于 6 。

示例 2：

输入：nums = [10,12,13,14,15]
输出：11
解释：我们可以将数组中所有元素变为回文数 11 得到等数数组，数组变成 [11,11,11,11,11] 需要执行 5 次特殊操作，代价为 |10 - 11| + |12 - 11| + |13 - 11| + |14 - 11| + |15 - 11| = 11 。
将所有元素变为其他回文数的总代价都大于 11 。

示例 3 ：

输入：nums = [22,33,22,33,22]
输出：22
解释：我们可以将数组中所有元素变为回文数 22 得到等数数组，数组变为 [22,22,22,22,22] 需要执行 2 次特殊操作，代价为 |33 - 22| + |33 - 22| = 22 。
将所有元素变为其他回文数的总代价都大于 22 。

提示：

1 <= n <= 105
1 <= nums[i] <= 109
"""
class Solution:
    def minimumCost(self, nums: List[int]) -> int:

给你一个长度为 n下标从 0开始的整数数组nums。
你可以对 nums执行特殊操作 任意次（也可以 0次）。每一次特殊操作中，你需要 按顺序执行以下步骤：

从范围[0, n - 1]里选择一个下标 i和一个 正整数x。
将|nums[i] - x|添加到总代价里。
将 nums[i]变为x。

如果一个正整数正着读和反着读都相同，那么我们称这个数是回文数。比方说，121，2552 和65756都是回文数，但是24，46，235都不是回文数。
如果一个数组中的所有元素都等于一个整数y，且y是一个小于109的回文数，那么我们称这个数组是一个 等数数组。
请你返回一个整数，表示执行任意次特殊操作后使 nums成为 等数数组的 最小总代价。

示例 1：

输入：nums = [1,2,3,4,5]
输出：6
解释：我们可以将数组中所有元素变为回文数 3 得到等数数组，数组变成 [3,3,3,3,3] 需要执行 4 次特殊操作，代价为 |1 - 3| + |2 - 3| + |4 - 3| + |5 - 3| = 6 。
将所有元素变为其他回文数的总代价都大于 6 。

示例 2：

输入：nums = [10,12,13,14,15]
输出：11
解释：我们可以将数组中所有元素变为回文数 11 得到等数数组，数组变成 [11,11,11,11,11] 需要执行 5 次特殊操作，代价为 |10 - 11| + |12 - 11| + |13 - 11| + |14 - 11| + |15 - 11| = 11 。
将所有元素变为其他回文数的总代价都大于 11 。

示例 3 ：

输入：nums = [22,33,22,33,22]
输出：22
解释：我们可以将数组中所有元素变为回文数 22 得到等数数组，数组变为 [22,22,22,22,22] 需要执行 2 次特殊操作，代价为 |33 - 22| + |33 - 22| = 22 。
将所有元素变为其他回文数的总代价都大于 22 。

提示：

1 <= n <= 105
1 <= nums[i] <= 109

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

```

my_solution = Solution()

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

test_input = { "nums": [10,12,13,14,15] }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [22,33,22,33,22] }
assert my_solution.minimumCost(**test_input) == 22

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

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

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

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

test_input = { "nums": [5] }
assert my_solution.minimumCost(**test_input) == 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [301,309,312,322] }
assert my_solution.minimumCost(**test_input) == 26

test_input = { "nums": [302,306,316,329] }
assert my_solution.minimumCost(**test_input) == 37

test_input = { "nums": [302,315,317,320] }
assert my_solution.minimumCost(**test_input) == 24

test_input = { "nums": [304,310,324,328] }
assert my_solution.minimumCost(**test_input) == 38

test_input = { "nums": [307,321,322,327] }
assert my_solution.minimumCost(**test_input) == 23

test_input = { "nums": [307,323,325,330] }
assert my_solution.minimumCost(**test_input) == 25

test_input = { "nums": [308,313,319,322] }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [311,313,320,324] }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [313,318,323,328] }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [101,102,105,108,124] }
assert my_solution.minimumCost(**test_input) == 35

test_input = { "nums": [101,102,105,120,124] }
assert my_solution.minimumCost(**test_input) == 47

test_input = { "nums": [101,102,111,125,126] }
assert my_solution.minimumCost(**test_input) == 48

test_input = { "nums": [101,104,107,126,130] }
assert my_solution.minimumCost(**test_input) == 55

test_input = { "nums": [101,106,113,120,124] }
assert my_solution.minimumCost(**test_input) == 39

test_input = { "nums": [101,115,116,120,122] }
assert my_solution.minimumCost(**test_input) == 33

test_input = { "nums": [102,103,105,106,109] }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [102,103,107,125,128] }
assert my_solution.minimumCost(**test_input) == 52

test_input = { "nums": [102,103,111,119,125] }
assert my_solution.minimumCost(**test_input) == 39

test_input = { "nums": [102,105,120,128,129] }
assert my_solution.minimumCost(**test_input) == 51

test_input = { "nums": [103,104,113,116,119] }
assert my_solution.minimumCost(**test_input) == 30

test_input = { "nums": [103,105,107,113,125] }
assert my_solution.minimumCost(**test_input) == 34

test_input = { "nums": [103,106,113,120,130] }
assert my_solution.minimumCost(**test_input) == 43

test_input = { "nums": [103,109,110,118,123] }
assert my_solution.minimumCost(**test_input) == 30

test_input = { "nums": [103,110,121,127,129] }
assert my_solution.minimumCost(**test_input) == 43

test_input = { "nums": [103,114,120,123,125] }
assert my_solution.minimumCost(**test_input) == 32

test_input = { "nums": [103,115,120,122,128] }
assert my_solution.minimumCost(**test_input) == 33

test_input = { "nums": [104,107,120,122,124] }
assert my_solution.minimumCost(**test_input) == 36

test_input = { "nums": [104,111,121,128,129] }
assert my_solution.minimumCost(**test_input) == 42

test_input = { "nums": [104,119,123,125,126] }
assert my_solution.minimumCost(**test_input) == 30

test_input = { "nums": [105,108,112,119,130] }
assert my_solution.minimumCost(**test_input) == 37

test_input = { "nums": [105,108,122,126,130] }
assert my_solution.minimumCost(**test_input) == 44

test_input = { "nums": [105,110,118,123,125] }
assert my_solution.minimumCost(**test_input) == 36

test_input = { "nums": [105,116,118,123,129] }
assert my_solution.minimumCost(**test_input) == 34

test_input = { "nums": [106,107,114,117,127] }
assert my_solution.minimumCost(**test_input) == 34

test_input = { "nums": [106,109,118,124,125] }
assert my_solution.minimumCost(**test_input) == 37

test_input = { "nums": [106,111,113,123,129] }
assert my_solution.minimumCost(**test_input) == 37

test_input = { "nums": [106,113,116,120,122] }
assert my_solution.minimumCost(**test_input) == 30

test_input = { "nums": [107,108,113,114,122] }
assert my_solution.minimumCost(**test_input) == 23

test_input = { "nums": [107,109,112,118,128] }
assert my_solution.minimumCost(**test_input) == 31

test_input = { "nums": [107,109,115,116,129] }
assert my_solution.minimumCost(**test_input) == 33

test_input = { "nums": [107,110,119,125,130] }
assert my_solution.minimumCost(**test_input) == 40

test_input = { "nums": [107,112,116,121,124] }
assert my_solution.minimumCost(**test_input) == 31

test_input = { "nums": [107,115,116,120,127] }
assert my_solution.minimumCost(**test_input) == 32

test_input = { "nums": [107,116,123,125,128] }
assert my_solution.minimumCost(**test_input) == 32

test_input = { "nums": [108,110,116,121,130] }
assert my_solution.minimumCost(**test_input) == 38

test_input = { "nums": [108,113,114,115,119] }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [108,113,116,124,129] }
assert my_solution.minimumCost(**test_input) == 37

test_input = { "nums": [108,115,124,127,129] }
assert my_solution.minimumCost(**test_input) == 36

test_input = { "nums": [109,113,115,122,128] }
assert my_solution.minimumCost(**test_input) == 34

test_input = { "nums": [110,111,112,126,129] }
assert my_solution.minimumCost(**test_input) == 35

test_input = { "nums": [110,113,119,124,125] }
assert my_solution.minimumCost(**test_input) == 28

test_input = { "nums": [111,114,117,118,125] }
assert my_solution.minimumCost(**test_input) == 28

test_input = { "nums": [112,113,114,120,130] }
assert my_solution.minimumCost(**test_input) == 34

test_input = { "nums": [112,115,120,123,129] }
assert my_solution.minimumCost(**test_input) == 26

test_input = { "nums": [117,118,119,124,128] }
assert my_solution.minimumCost(**test_input) == 19

test_input = { "nums": [201,202,203,205,215,228] }
assert my_solution.minimumCost(**test_input) == 44

test_input = { "nums": [201,202,204,205,215,225] }
assert my_solution.minimumCost(**test_input) == 42

test_input = { "nums": [201,202,204,207,220,224] }
assert my_solution.minimumCost(**test_input) == 48

test_input = { "nums": [201,202,204,208,216,225] }
assert my_solution.minimumCost(**test_input) == 46

test_input = { "nums": [201,202,204,218,223,224] }
assert my_solution.minimumCost(**test_input) == 58

test_input = { "nums": [201,202,205,210,227,228] }
assert my_solution.minimumCost(**test_input) == 61

test_input = { "nums": [201,202,205,211,214,225] }
assert my_solution.minimumCost(**test_input) == 44

test_input = { "nums": [201,202,207,210,223,226] }
assert my_solution.minimumCost(**test_input) == 53

test_input = { "nums": [201,202,207,212,215,222] }
assert my_solution.minimumCost(**test_input) == 39

test_input = { "nums": [201,202,207,216,220,223] }
assert my_solution.minimumCost(**test_input) == 49

test_input = { "nums": [201,202,211,213,221,223] }
assert my_solution.minimumCost(**test_input) == 43

test_input = { "nums": [201,202,212,213,219,229] }
assert my_solution.minimumCost(**test_input) == 46


apply-operations-to-maximize-frequency-score

Apply Operations to Maximize Frequency Score

Prompt:
"""
给你一个下标从 0开始的整数数组nums和一个整数k。
你可以对数组执行 至多k次操作：

从数组中选择一个下标 i，将nums[i] 增加或者减少1。

最终数组的频率分数定义为数组中众数的 频率。
请你返回你可以得到的 最大频率分数。
众数指的是数组中出现次数最多的数。一个元素的频率指的是数组中这个元素的出现次数。

示例 1：

输入：nums = [1,2,6,4], k = 3
输出：3
解释：我们可以对数组执行以下操作：
- 选择 i = 0 ，将 nums[0] 增加 1 。得到数组 [2,2,6,4] 。
- 选择 i = 3 ，将 nums[3] 减少 1 ，得到数组 [2,2,6,3] 。
- 选择 i = 3 ，将 nums[3] 减少 1 ，得到数组 [2,2,6,2] 。
元素 2 是最终数组中的众数，出现了 3 次，所以频率分数为 3 。
3 是所有可行方案里的最大频率分数。

示例 2：

输入：nums = [1,4,4,2,4], k = 0
输出：3
解释：我们无法执行任何操作，所以得到的频率分数是原数组中众数的频率 3 。

提示：

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

给你一个下标从 0开始的整数数组nums和一个整数k。
你可以对数组执行 至多k次操作：

从数组中选择一个下标 i，将nums[i] 增加或者减少1。

最终数组的频率分数定义为数组中众数的 频率。
请你返回你可以得到的 最大频率分数。
众数指的是数组中出现次数最多的数。一个元素的频率指的是数组中这个元素的出现次数。

示例 1：

输入：nums = [1,2,6,4], k = 3
输出：3
解释：我们可以对数组执行以下操作：
- 选择 i = 0 ，将 nums[0] 增加 1 。得到数组 [2,2,6,4] 。
- 选择 i = 3 ，将 nums[3] 减少 1 ，得到数组 [2,2,6,3] 。
- 选择 i = 3 ，将 nums[3] 减少 1 ，得到数组 [2,2,6,2] 。
元素 2 是最终数组中的众数，出现了 3 次，所以频率分数为 3 。
3 是所有可行方案里的最大频率分数。

示例 2：

输入：nums = [1,4,4,2,4], k = 0
输出：3
解释：我们无法执行任何操作，所以得到的频率分数是原数组中众数的频率 3 。

提示：

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

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

```

my_solution = Solution()

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

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

test_input = { "nums": [3,20,13,2,3,15,24,19,8,13,19,20,21], "k": 45 }
assert my_solution.maxFrequencyScore(**test_input) == 10

test_input = { "nums": [13,22,29,21,13,17,5,2,27,6,10,4,23,29,27], "k": 117 }
assert my_solution.maxFrequencyScore(**test_input) == 14

test_input = { "nums": [27,8,30,3,13,28,7,14,21,19,24,28,29,1,14,22,6], "k": 23 }
assert my_solution.maxFrequencyScore(**test_input) == 8

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

test_input = { "nums": [10,19,26,18,27,18], "k": 9 }
assert my_solution.maxFrequencyScore(**test_input) == 4

test_input = { "nums": [17,24,10,23,22,15,25,2,13,24,22,25,25,21], "k": 52 }
assert my_solution.maxFrequencyScore(**test_input) == 13

test_input = { "nums": [28,6,22,10], "k": 12 }
assert my_solution.maxFrequencyScore(**test_input) == 2

test_input = { "nums": [17,17,25,14,29,28,20,14,16,22,4,28,2,5,3,11,6,20,17], "k": 76 }
assert my_solution.maxFrequencyScore(**test_input) == 14

test_input = { "nums": [23,10,18,21,16,23,14], "k": 2 }
assert my_solution.maxFrequencyScore(**test_input) == 3

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

test_input = { "nums": [6,29,3,19,10,6,20,26,1,30,11,25,29,12,29,14,15,16,5], "k": 64 }
assert my_solution.maxFrequencyScore(**test_input) == 12

test_input = { "nums": [10,26,21,18,30,25,1], "k": 8 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [29,10,26,1,2,2,17,7,5,16,24,27,7,7,26,26,24], "k": 3 }
assert my_solution.maxFrequencyScore(**test_input) == 5

test_input = { "nums": [11,16,6,12,3,8,5,29,9,15,7,9,14,6,11,14,12,23,22,14], "k": 79 }
assert my_solution.maxFrequencyScore(**test_input) == 19

test_input = { "nums": [5,17,15,14,27,11,22,6,4], "k": 26 }
assert my_solution.maxFrequencyScore(**test_input) == 6

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

test_input = { "nums": [24,6,14,6,30,9,6,11,21,10,12,27,1], "k": 90 }
assert my_solution.maxFrequencyScore(**test_input) == 13

test_input = { "nums": [19,5,2,23,16,22,3,2,5,20,17,3,22,1], "k": 15 }
assert my_solution.maxFrequencyScore(**test_input) == 7

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

test_input = { "nums": [9,2,5,14,19,5,10,10,2,25,1,1,1,14,9,13,5,6,10,1], "k": 80 }
assert my_solution.maxFrequencyScore(**test_input) == 18

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

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

test_input = { "nums": [5,2,22,7,18,26,15,4,24,26,24], "k": 19 }
assert my_solution.maxFrequencyScore(**test_input) == 6

test_input = { "nums": [23,21,10], "k": 13 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [5,23,7,2,1,5,12,2,20,24,5,4], "k": 71 }
assert my_solution.maxFrequencyScore(**test_input) == 11

test_input = { "nums": [22,13,30], "k": 17 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [7,23,29,8,9,3,4,16,24,6,18,20,19,14,5], "k": 55 }
assert my_solution.maxFrequencyScore(**test_input) == 11

test_input = { "nums": [3,11,24,27,10], "k": 24 }
assert my_solution.maxFrequencyScore(**test_input) == 4

test_input = { "nums": [12,11,21,6,13,27,11,2,27,26,24,13], "k": 0 }
assert my_solution.maxFrequencyScore(**test_input) == 2

test_input = { "nums": [4,10,26,16,21,26,11,26,30,24,18,30,23,26,24], "k": 50 }
assert my_solution.maxFrequencyScore(**test_input) == 12

test_input = { "nums": [4,2,18,14,9,29], "k": 4 }
assert my_solution.maxFrequencyScore(**test_input) == 2

test_input = { "nums": [9,27,19,18], "k": 9 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [11,17,29,9,22,7,13,14,12,24,9], "k": 47 }
assert my_solution.maxFrequencyScore(**test_input) == 10

test_input = { "nums": [20,10,15,16], "k": 10 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [16,2,6,20,2,18,16,8,15,19,22,29,24,2,26,19], "k": 40 }
assert my_solution.maxFrequencyScore(**test_input) == 11

test_input = { "nums": [17,13,19,28,6,8,5,25,2,3,9,4,21,6,13,10,5,3], "k": 113 }
assert my_solution.maxFrequencyScore(**test_input) == 18

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

test_input = { "nums": [23,2,23,27,21], "k": 2 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [15,26,3,14,3,18,16,19,11,9,2,18,14,8,20,9], "k": 75 }
assert my_solution.maxFrequencyScore(**test_input) == 15

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

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

test_input = { "nums": [4,27,21,16,11,5,5,1,5,10], "k": 18 }
assert my_solution.maxFrequencyScore(**test_input) == 7

test_input = { "nums": [14,4,23,27,8,25,7,12,12,21,21,11,20,23,30,11,12,29,22], "k": 77 }
assert my_solution.maxFrequencyScore(**test_input) == 15

test_input = { "nums": [10,30,25], "k": 20 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [4,8,22,25,27,26,18,14,18], "k": 56 }
assert my_solution.maxFrequencyScore(**test_input) == 9

test_input = { "nums": [2,19,27,25,23,17,8,16,28,10,6,24,6], "k": 28 }
assert my_solution.maxFrequencyScore(**test_input) == 7

test_input = { "nums": [27,25,27,10,23,14,24,17,12,22,14,11,19,16,7,15], "k": 21 }
assert my_solution.maxFrequencyScore(**test_input) == 9

test_input = { "nums": [23,11], "k": 12 }
assert my_solution.maxFrequencyScore(**test_input) == 2

test_input = { "nums": [20,28,15,11,22,26,29,2,16,9], "k": 61 }
assert my_solution.maxFrequencyScore(**test_input) == 9

test_input = { "nums": [21,11,1,17,20,19,24,10,1,4,10,30,11,29,20,12,18,5,4,27], "k": 110 }
assert my_solution.maxFrequencyScore(**test_input) == 17

test_input = { "nums": [22,29,7,1,26,22,27,1,16,25,25], "k": 26 }
assert my_solution.maxFrequencyScore(**test_input) == 8

test_input = { "nums": [26,6,24], "k": 20 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [29,24,9,4,2,9,28,1,25,25,13,22,27,26,15,18], "k": 2 }
assert my_solution.maxFrequencyScore(**test_input) == 4

test_input = { "nums": [9,19,1,24,15,19,22,13,10,8,4,10,26,23,11,8], "k": 89 }
assert my_solution.maxFrequencyScore(**test_input) == 15

test_input = { "nums": [18,6,20,22,25,21,19,19,15,5,7,29,28,7,17,4], "k": 104 }
assert my_solution.maxFrequencyScore(**test_input) == 16

test_input = { "nums": [9,11,28,24,30,6,1,30,22,16,20,19,21,17], "k": 62 }
assert my_solution.maxFrequencyScore(**test_input) == 11

test_input = { "nums": [15,13,29,28], "k": 15 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [28,26,8], "k": 18 }
assert my_solution.maxFrequencyScore(**test_input) == 2

test_input = { "nums": [6,12,24,4,25,23,5,13,7,5], "k": 12 }
assert my_solution.maxFrequencyScore(**test_input) == 6

test_input = { "nums": [8,23,15,15,3,19,6,20,12,18,7,8,18,19,11,20,4,18], "k": 54 }
assert my_solution.maxFrequencyScore(**test_input) == 14

test_input = { "nums": [30,2,4,7,19,3,3,14,24,4,26,17,1,12,4,11], "k": 36 }
assert my_solution.maxFrequencyScore(**test_input) == 11

test_input = { "nums": [12,15,21,17,7,20,16,30,8,6,28,28,23,6,12,14,19,26,27,5], "k": 87 }
assert my_solution.maxFrequencyScore(**test_input) == 16

test_input = { "nums": [15,1,27,4,5,20,5,26,28], "k": 38 }
assert my_solution.maxFrequencyScore(**test_input) == 6

test_input = { "nums": [27,14,30,6,14,29,5,8], "k": 51 }
assert my_solution.maxFrequencyScore(**test_input) == 7

test_input = { "nums": [18,22], "k": 4 }
assert my_solution.maxFrequencyScore(**test_input) == 2

test_input = { "nums": [17,28,16,24,29], "k": 5 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [2,22,27,12,30,9,27,3,26,23,25,30,20,19,9,1,23,14,18,26], "k": 30 }
assert my_solution.maxFrequencyScore(**test_input) == 11

test_input = { "nums": [26,16,9,7,10,16,26,22,24,1,30,8,15,5,28,16,13,12], "k": 84 }
assert my_solution.maxFrequencyScore(**test_input) == 15

test_input = { "nums": [26,8,27,27,22,28,8,26,24,15,6,13,20,12], "k": 55 }
assert my_solution.maxFrequencyScore(**test_input) == 11

test_input = { "nums": [19,19,20,14,19,20,5,4,14,26,12,17,14,29,3,9], "k": 94 }
assert my_solution.maxFrequencyScore(**test_input) == 16

test_input = { "nums": [9,19,14,17,14,20,27,9,22,29,15,20,6,25,8,17,18,24,23], "k": 44 }
assert my_solution.maxFrequencyScore(**test_input) == 13

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

test_input = { "nums": [20,2,27,27,19,20,8,21,15,20,14,18,25], "k": 17 }
assert my_solution.maxFrequencyScore(**test_input) == 8

test_input = { "nums": [6,27,6,30,2,1,7,24,18,4,2,18,17], "k": 56 }
assert my_solution.maxFrequencyScore(**test_input) == 10

test_input = { "nums": [23,18,30,24,5,21], "k": 33 }
assert my_solution.maxFrequencyScore(**test_input) == 6

test_input = { "nums": [12,16,24,18,12,20,26,15,11,23,4,25], "k": 35 }
assert my_solution.maxFrequencyScore(**test_input) == 9

test_input = { "nums": [9,9,11,18], "k": 11 }
assert my_solution.maxFrequencyScore(**test_input) == 4

test_input = { "nums": [19,21,7,15,21,10,5,27,2,27,14], "k": 63 }
assert my_solution.maxFrequencyScore(**test_input) == 9

test_input = { "nums": [25,17,13,6,3,19,21,12,29,1,16,14,24,27,25,13,1,5,17], "k": 136 }
assert my_solution.maxFrequencyScore(**test_input) == 19

test_input = { "nums": [4,4,8,9,14,7,27,8,2,29,1,28,23,13], "k": 109 }
assert my_solution.maxFrequencyScore(**test_input) == 14

test_input = { "nums": [14,2,18,30,28,17,25,10,7,10,19,3,26,22,12,17,8,4], "k": 24 }
assert my_solution.maxFrequencyScore(**test_input) == 8

test_input = { "nums": [27,17,12,19,25,1,9,4,9,20,2,5], "k": 70 }
assert my_solution.maxFrequencyScore(**test_input) == 10

test_input = { "nums": [18,25,12,20,19,26,2,15,3,6,29,29,2,24,4,9], "k": 106 }
assert my_solution.maxFrequencyScore(**test_input) == 14

test_input = { "nums": [17,18,14,1,28,15,14,13,9,16,28,9,21,23,2,11], "k": 65 }
assert my_solution.maxFrequencyScore(**test_input) == 14

test_input = { "nums": [17,15,29,30,12,13,10], "k": 37 }
assert my_solution.maxFrequencyScore(**test_input) == 6

test_input = { "nums": [15,4,11,1,18,29,9,23,14,25,15,12,15,6,30,28], "k": 60 }
assert my_solution.maxFrequencyScore(**test_input) == 12

test_input = { "nums": [20,6,8,15,12,8,26,7,27,8,5,25,17,12,7,1,23,24,8], "k": 62 }
assert my_solution.maxFrequencyScore(**test_input) == 14

test_input = { "nums": [22,21,30,16,23,24,2,2,24], "k": 39 }
assert my_solution.maxFrequencyScore(**test_input) == 7

test_input = { "nums": [8,9,6,30,28,2,1,3,14,8,21,26,13,29,23,3,14,9,6,25], "k": 91 }
assert my_solution.maxFrequencyScore(**test_input) == 16

test_input = { "nums": [7,10,16,23,17,22,28,7,4,21,25,21,19,30,13,19,15,21,23], "k": 53 }
assert my_solution.maxFrequencyScore(**test_input) == 15

test_input = { "nums": [25,17,1,24,3,6,8,29,19,4,16,12,9,28,1,21,13,29], "k": 151 }
assert my_solution.maxFrequencyScore(**test_input) == 18

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

test_input = { "nums": [5,7,17,2,23,6,3,13,2,11,10,8,18,16,3,11,26], "k": 30 }
assert my_solution.maxFrequencyScore(**test_input) == 10

test_input = { "nums": [27,27,16,18,24,7,26,30,21,25,28,28,29,27,28,6], "k": 0 }
assert my_solution.maxFrequencyScore(**test_input) == 3

test_input = { "nums": [29,16,9,21,2,16,4,17,22,11,20,23,5,22,7,27,20], "k": 85 }
assert my_solution.maxFrequencyScore(**test_input) == 15

test_input = { "nums": [25,5,24,2,30,15,17,27,15,15,27], "k": 69 }
assert my_solution.maxFrequencyScore(**test_input) == 10

test_input = { "nums": [6,29,24,14,9,14,1,1,28,20,19,21,13,25,17,24,30,14], "k": 107 }
assert my_solution.maxFrequencyScore(**test_input) == 16

test_input = { "nums": [17,20,2,11,5,7,28], "k": 36 }
assert my_solution.maxFrequencyScore(**test_input) == 6


count-tested-devices-after-test-operations

Count Tested Devices After Test Operations

Prompt:
"""
给你一个长度为 n 、下标从 0 开始的整数数组 batteryPercentages ，表示 n 个设备的电池百分比。
你的任务是按照顺序测试每个设备 i，执行以下测试操作：

如果 batteryPercentages[i] 大于 0：

增加 已测试设备的计数。
将下标在 [i + 1, n - 1] 的所有设备的电池百分比减少 1，确保它们的电池百分比 不会低于 0 ，即 batteryPercentages[j] = max(0, batteryPercentages[j] - 1)。
移动到下一个设备。

否则，移动到下一个设备而不执行任何测试。

返回一个整数，表示按顺序执行测试操作后 已测试设备 的数量。

示例 1：

输入：batteryPercentages = [1,1,2,1,3]
输出：3
解释：按顺序从设备 0 开始执行测试操作：
在设备 0 上，batteryPercentages[0] > 0 ，现在有 1 个已测试设备，batteryPercentages 变为 [1,0,1,0,2] 。
在设备 1 上，batteryPercentages[1] == 0 ，移动到下一个设备而不进行测试。
在设备 2 上，batteryPercentages[2] > 0 ，现在有 2 个已测试设备，batteryPercentages 变为 [1,0,1,0,1] 。
在设备 3 上，batteryPercentages[3] == 0 ，移动到下一个设备而不进行测试。
在设备 4 上，batteryPercentages[4] > 0 ，现在有 3 个已测试设备，batteryPercentages 保持不变。
因此，答案是 3 。

示例 2：

输入：batteryPercentages = [0,1,2]
输出：2
解释：按顺序从设备 0 开始执行测试操作：
在设备 0 上，batteryPercentages[0] == 0 ，移动到下一个设备而不进行测试。
在设备 1 上，batteryPercentages[1] > 0 ，现在有 1 个已测试设备，batteryPercentages 变为 [0,1,1] 。
在设备 2 上，batteryPercentages[2] > 0 ，现在有 2 个已测试设备，batteryPercentages 保持不变。
因此，答案是 2 。

提示：

1 <= n == batteryPercentages.length <= 100
0 <= batteryPercentages[i] <= 100
"""
class Solution:
    def countTestedDevices(self, batteryPercentages: List[int]) -> int:

给你一个长度为 n 、下标从 0 开始的整数数组 batteryPercentages ，表示 n 个设备的电池百分比。
你的任务是按照顺序测试每个设备 i，执行以下测试操作：

如果 batteryPercentages[i] 大于 0：

增加 已测试设备的计数。
将下标在 [i + 1, n - 1] 的所有设备的电池百分比减少 1，确保它们的电池百分比 不会低于 0 ，即 batteryPercentages[j] = max(0, batteryPercentages[j] - 1)。
移动到下一个设备。

否则，移动到下一个设备而不执行任何测试。

返回一个整数，表示按顺序执行测试操作后 已测试设备 的数量。

示例 1：

输入：batteryPercentages = [1,1,2,1,3]
输出：3
解释：按顺序从设备 0 开始执行测试操作：
在设备 0 上，batteryPercentages[0] > 0 ，现在有 1 个已测试设备，batteryPercentages 变为 [1,0,1,0,2] 。
在设备 1 上，batteryPercentages[1] == 0 ，移动到下一个设备而不进行测试。
在设备 2 上，batteryPercentages[2] > 0 ，现在有 2 个已测试设备，batteryPercentages 变为 [1,0,1,0,1] 。
在设备 3 上，batteryPercentages[3] == 0 ，移动到下一个设备而不进行测试。
在设备 4 上，batteryPercentages[4] > 0 ，现在有 3 个已测试设备，batteryPercentages 保持不变。
因此，答案是 3 。

示例 2：

输入：batteryPercentages = [0,1,2]
输出：2
解释：按顺序从设备 0 开始执行测试操作：
在设备 0 上，batteryPercentages[0] == 0 ，移动到下一个设备而不进行测试。
在设备 1 上，batteryPercentages[1] > 0 ，现在有 1 个已测试设备，batteryPercentages 变为 [0,1,1] 。
在设备 2 上，batteryPercentages[2] > 0 ，现在有 2 个已测试设备，batteryPercentages 保持不变。
因此，答案是 2 。

提示：

1 <= n == batteryPercentages.length <= 100
0 <= batteryPercentages[i] <= 100

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

```

my_solution = Solution()

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

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

test_input = { "batteryPercentages": [0] }
assert my_solution.countTestedDevices(**test_input) == 0

test_input = { "batteryPercentages": [1] }
assert my_solution.countTestedDevices(**test_input) == 1

test_input = { "batteryPercentages": [0,0] }
assert my_solution.countTestedDevices(**test_input) == 0

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

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

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

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

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

test_input = { "batteryPercentages": [2,2] }
assert my_solution.countTestedDevices(**test_input) == 2

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

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

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

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

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

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

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

test_input = { "batteryPercentages": [2,2,2] }
assert my_solution.countTestedDevices(**test_input) == 2

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

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

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

test_input = { "batteryPercentages": [0,2,1,4] }
assert my_solution.countTestedDevices(**test_input) == 2

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

test_input = { "batteryPercentages": [3,1,2,0] }
assert my_solution.countTestedDevices(**test_input) == 2

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

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

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

test_input = { "batteryPercentages": [4,2,0,1] }
assert my_solution.countTestedDevices(**test_input) == 2

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

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

test_input = { "batteryPercentages": [0,3,1,3,5] }
assert my_solution.countTestedDevices(**test_input) == 3

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

test_input = { "batteryPercentages": [0,5,4,2,0] }
assert my_solution.countTestedDevices(**test_input) == 2

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

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

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

test_input = { "batteryPercentages": [4,3,3,5,4] }
assert my_solution.countTestedDevices(**test_input) == 4

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

test_input = { "batteryPercentages": [5,5,5,2,0] }
assert my_solution.countTestedDevices(**test_input) == 3

test_input = { "batteryPercentages": [0,2,4,3,0,2] }
assert my_solution.countTestedDevices(**test_input) == 3

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

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

test_input = { "batteryPercentages": [1,6,0,3,3,6] }
assert my_solution.countTestedDevices(**test_input) == 4

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

test_input = { "batteryPercentages": [3,2,6,2,6,0] }
assert my_solution.countTestedDevices(**test_input) == 4

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

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

test_input = { "batteryPercentages": [4,5,2,3,6,2] }
assert my_solution.countTestedDevices(**test_input) == 4

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

test_input = { "batteryPercentages": [5,1,6,6,3,6] }
assert my_solution.countTestedDevices(**test_input) == 4

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

test_input = { "batteryPercentages": [6,2,2,3,4,6] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [6,2,3,0,2,0] }
assert my_solution.countTestedDevices(**test_input) == 3

test_input = { "batteryPercentages": [1,0,6,3,6,3,1] }
assert my_solution.countTestedDevices(**test_input) == 4

test_input = { "batteryPercentages": [2,1,7,3,0,3,3] }
assert my_solution.countTestedDevices(**test_input) == 3

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

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

test_input = { "batteryPercentages": [2,5,2,7,6,5,5] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [4,2,6,4,7,6,7] }
assert my_solution.countTestedDevices(**test_input) == 7

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

test_input = { "batteryPercentages": [4,4,3,0,2,6,6] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [5,2,2,3,4,6,6] }
assert my_solution.countTestedDevices(**test_input) == 6

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

test_input = { "batteryPercentages": [6,6,7,0,1,7,2] }
assert my_solution.countTestedDevices(**test_input) == 4

test_input = { "batteryPercentages": [0,5,1,4,5,0,4,8] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [1,0,7,0,7,4,5,7] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [2,5,3,4,4,8,6,5] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [2,6,3,4,5,6,2,6] }
assert my_solution.countTestedDevices(**test_input) == 6

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

test_input = { "batteryPercentages": [6,5,4,8,6,8,3,6] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [7,4,0,8,5,5,2,0] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [7,5,3,2,3,5,8,6] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [8,0,4,3,2,6,6,1] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [8,3,0,1,0,8,6,8] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [8,6,7,1,0,1,3,7] }
assert my_solution.countTestedDevices(**test_input) == 4

test_input = { "batteryPercentages": [0,6,8,8,0,1,2,3,4] }
assert my_solution.countTestedDevices(**test_input) == 4

test_input = { "batteryPercentages": [2,7,9,7,2,9,0,3,9] }
assert my_solution.countTestedDevices(**test_input) == 6

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

test_input = { "batteryPercentages": [8,4,0,1,1,6,5,3,5] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [8,4,1,5,8,5,8,7,9] }
assert my_solution.countTestedDevices(**test_input) == 8

test_input = { "batteryPercentages": [8,4,9,8,9,0,0,4,9] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [8,9,4,4,1,9,8,9,1] }
assert my_solution.countTestedDevices(**test_input) == 7

test_input = { "batteryPercentages": [2,5,8,9,1,5,10,9,6,3] }
assert my_solution.countTestedDevices(**test_input) == 7

test_input = { "batteryPercentages": [2,6,5,4,1,5,3,3,3,9] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [7,7,7,3,6,6,4,3,5,10] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [9,3,10,1,8,2,4,3,3,0] }
assert my_solution.countTestedDevices(**test_input) == 4

test_input = { "batteryPercentages": [10,10,2,0,2,7,6,7,10,4] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [0,8,7,9,4,10,4,3,7,11,7] }
assert my_solution.countTestedDevices(**test_input) == 7

test_input = { "batteryPercentages": [1,2,3,5,6,11,3,2,11,0,8] }
assert my_solution.countTestedDevices(**test_input) == 8

test_input = { "batteryPercentages": [5,10,4,10,10,6,8,1,8,10,3] }
assert my_solution.countTestedDevices(**test_input) == 9

test_input = { "batteryPercentages": [7,10,2,7,11,8,11,4,1,4,5] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [7,11,0,4,1,10,5,3,2,0,2] }
assert my_solution.countTestedDevices(**test_input) == 5

test_input = { "batteryPercentages": [8,8,1,8,6,2,5,2,8,5,6] }
assert my_solution.countTestedDevices(**test_input) == 6

test_input = { "batteryPercentages": [8,9,10,10,1,5,4,6,7,2,4] }
assert my_solution.countTestedDevices(**test_input) == 7

test_input = { "batteryPercentages": [9,9,2,3,2,2,9,6,11,1,10] }
assert my_solution.countTestedDevices(**test_input) == 7

test_input = { "batteryPercentages": [10,0,6,2,6,6,11,1,8,10,5] }
assert my_solution.countTestedDevices(**test_input) == 7

test_input = { "batteryPercentages": [1,4,7,2,12,8,1,11,5,10,2,3] }
assert my_solution.countTestedDevices(**test_input) == 7

test_input = { "batteryPercentages": [2,5,4,4,9,6,10,0,11,8,2,10] }
assert my_solution.countTestedDevices(**test_input) == 9

test_input = { "batteryPercentages": [4,11,9,8,9,11,11,5,11,6,12,11] }
assert my_solution.countTestedDevices(**test_input) == 10


double-modular-exponentiation

Double Modular Exponentiation

Prompt:
"""
给你一个下标从 0 开始的二维数组 variables ，其中 variables[i] = [ai, bi, ci, mi]，以及一个整数 target 。
如果满足以下公式，则下标 i 是 好下标：

0 <= i < variables.length
((aibi % 10)ci) % mi == target

返回一个由 好下标 组成的数组，顺序不限 。

示例 1：

输入：variables = [[2,3,3,10],[3,3,3,1],[6,1,1,4]], target = 2
输出：[0,2]
解释：对于 variables 数组中的每个下标 i ：
1) 对于下标 0 ，variables[0] = [2,3,3,10] ，(23 % 10)3 % 10 = 2 。
2) 对于下标 1 ，variables[1] = [3,3,3,1] ，(33 % 10)3 % 1 = 0 。
3) 对于下标 2 ，variables[2] = [6,1,1,4] ，(61 % 10)1 % 4 = 2 。
因此，返回 [0,2] 作为答案。

示例 2：

输入：variables = [[39,3,1000,1000]], target = 17
输出：[]
解释：对于 variables 数组中的每个下标 i ：
1) 对于下标 0 ，variables[0] = [39,3,1000,1000] ，(393 % 10)1000 % 1000 = 1 。
因此，返回 [] 作为答案。

提示：

1 <= variables.length <= 100
variables[i] == [ai, bi, ci, mi]
1 <= ai, bi, ci, mi <= 103
0 <= target <= 103
"""
class Solution:
    def getGoodIndices(self, variables: List[List[int]], target: int) -> List[int]:

给你一个下标从 0 开始的二维数组 variables ，其中 variables[i] = [ai, bi, ci, mi]，以及一个整数 target 。
如果满足以下公式，则下标 i 是 好下标：

0 <= i < variables.length
((aibi % 10)ci) % mi == target

返回一个由 好下标 组成的数组，顺序不限 。

示例 1：

输入：variables = [[2,3,3,10],[3,3,3,1],[6,1,1,4]], target = 2
输出：[0,2]
解释：对于 variables 数组中的每个下标 i ：
1) 对于下标 0 ，variables[0] = [2,3,3,10] ，(23 % 10)3 % 10 = 2 。
2) 对于下标 1 ，variables[1] = [3,3,3,1] ，(33 % 10)3 % 1 = 0 。
3) 对于下标 2 ，variables[2] = [6,1,1,4] ，(61 % 10)1 % 4 = 2 。
因此，返回 [0,2] 作为答案。

示例 2：

输入：variables = [[39,3,1000,1000]], target = 17
输出：[]
解释：对于 variables 数组中的每个下标 i ：
1) 对于下标 0 ，variables[0] = [39,3,1000,1000] ，(393 % 10)1000 % 1000 = 1 。
因此，返回 [] 作为答案。

提示：

1 <= variables.length <= 100
variables[i] == [ai, bi, ci, mi]
1 <= ai, bi, ci, mi <= 103
0 <= target <= 103

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

```


count-subarrays-where-max-element-appears-at-least-k-times

Count Subarrays Where Max Element Appears at Least K Times

Prompt:
"""
给你一个整数数组 nums 和一个 正整数 k 。
请你统计有多少满足 「nums 中的 最大 元素」至少出现 k 次的子数组，并返回满足这一条件的子数组的数目。
子数组是数组中的一个连续元素序列。

示例 1：

输入：nums = [1,3,2,3,3], k = 2
输出：6
解释：包含元素 3 至少 2 次的子数组为：[1,3,2,3]、[1,3,2,3,3]、[3,2,3]、[3,2,3,3]、[2,3,3] 和 [3,3] 。

示例 2：

输入：nums = [1,4,2,1], k = 3
输出：0
解释：没有子数组包含元素 4 至少 3 次。

提示：

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

给你一个整数数组 nums 和一个 正整数 k 。
请你统计有多少满足 「nums 中的 最大 元素」至少出现 k 次的子数组，并返回满足这一条件的子数组的数目。
子数组是数组中的一个连续元素序列。

示例 1：

输入：nums = [1,3,2,3,3], k = 2
输出：6
解释：包含元素 3 至少 2 次的子数组为：[1,3,2,3]、[1,3,2,3,3]、[3,2,3]、[3,2,3,3]、[2,3,3] 和 [3,3] 。

示例 2：

输入：nums = [1,4,2,1], k = 3
输出：0
解释：没有子数组包含元素 4 至少 3 次。

提示：

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

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

```


count-the-number-of-good-partitions

Count the Number of Good Partitions

Prompt:
"""
给你一个下标从 0 开始、由 正整数 组成的数组 nums。
将数组分割成一个或多个 连续 子数组，如果不存在包含了相同数字的两个子数组，则认为是一种 好分割方案 。
返回 nums 的 好分割方案 的 数目。
由于答案可能很大，请返回答案对 109 + 7 取余 的结果。

示例 1：

输入：nums = [1,2,3,4]
输出：8
解释：有 8 种 好分割方案 ：([1], [2], [3], [4]), ([1], [2], [3,4]), ([1], [2,3], [4]), ([1], [2,3,4]), ([1,2], [3], [4]), ([1,2], [3,4]), ([1,2,3], [4]) 和 ([1,2,3,4]) 。

示例 2：

输入：nums = [1,1,1,1]
输出：1
解释：唯一的 好分割方案 是：([1,1,1,1]) 。

示例 3：

输入：nums = [1,2,1,3]
输出：2
解释：有 2 种 好分割方案 ：([1,2,1], [3]) 和 ([1,2,1,3]) 。

提示：

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

给你一个下标从 0 开始、由 正整数 组成的数组 nums。
将数组分割成一个或多个 连续 子数组，如果不存在包含了相同数字的两个子数组，则认为是一种 好分割方案 。
返回 nums 的 好分割方案 的 数目。
由于答案可能很大，请返回答案对 109 + 7 取余 的结果。

示例 1：

输入：nums = [1,2,3,4]
输出：8
解释：有 8 种 好分割方案 ：([1], [2], [3], [4]), ([1], [2], [3,4]), ([1], [2,3], [4]), ([1], [2,3,4]), ([1,2], [3], [4]), ([1,2], [3,4]), ([1,2,3], [4]) 和 ([1,2,3,4]) 。

示例 2：

输入：nums = [1,1,1,1]
输出：1
解释：唯一的 好分割方案 是：([1,1,1,1]) 。

示例 3：

输入：nums = [1,2,1,3]
输出：2
解释：有 2 种 好分割方案 ：([1,2,1], [3]) 和 ([1,2,1,3]) 。

提示：

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

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

```

my_solution = Solution()

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

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

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

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

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

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

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

test_input = { "nums": [1,1,1,9,7] }
assert my_solution.numberOfGoodPartitions(**test_input) == 4

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

test_input = { "nums": [1,4,1,7,5] }
assert my_solution.numberOfGoodPartitions(**test_input) == 4

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

test_input = { "nums": [1,5,1,10,8] }
assert my_solution.numberOfGoodPartitions(**test_input) == 4

test_input = { "nums": [1,6,8,1,5] }
assert my_solution.numberOfGoodPartitions(**test_input) == 2

test_input = { "nums": [1,6,9,4,10] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [1,7,1,6,8] }
assert my_solution.numberOfGoodPartitions(**test_input) == 4

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

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

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

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

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

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

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

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

test_input = { "nums": [2,5,1,4,9] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

test_input = { "nums": [2,6,1,9,5] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [2,7,8,9,3] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

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

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

test_input = { "nums": [3,3,8,1,6] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

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

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

test_input = { "nums": [3,7,6,4,9] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [3,8,10,7,6] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

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

test_input = { "nums": [4,1,7,9,4] }
assert my_solution.numberOfGoodPartitions(**test_input) == 1

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

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

test_input = { "nums": [5,2,8,10,4] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

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

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

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

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

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

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

test_input = { "nums": [5,10,1,1,6] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

test_input = { "nums": [6,1,7,9,10] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [6,3,5,1,10] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

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

test_input = { "nums": [6,7,3,3,8] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

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

test_input = { "nums": [6,9,10,5,8] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

test_input = { "nums": [6,10,5,4,3] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

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

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

test_input = { "nums": [7,5,1,10,10] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

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

test_input = { "nums": [7,5,8,4,6] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [7,9,4,8,7] }
assert my_solution.numberOfGoodPartitions(**test_input) == 1

test_input = { "nums": [7,9,8,8,4] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

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

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

test_input = { "nums": [8,3,4,9,7] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [8,3,6,5,1] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

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

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

test_input = { "nums": [8,4,8,10,9] }
assert my_solution.numberOfGoodPartitions(**test_input) == 4

test_input = { "nums": [8,5,5,3,9] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

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

test_input = { "nums": [8,7,6,10,1] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [8,9,7,3,6] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [8,10,5,9,9] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

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

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

test_input = { "nums": [9,1,7,8,9] }
assert my_solution.numberOfGoodPartitions(**test_input) == 1

test_input = { "nums": [9,2,7,5,10] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

test_input = { "nums": [9,4,7,1,1] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

test_input = { "nums": [9,5,5,8,3] }
assert my_solution.numberOfGoodPartitions(**test_input) == 8

test_input = { "nums": [9,7,2,7,10] }
assert my_solution.numberOfGoodPartitions(**test_input) == 4

test_input = { "nums": [9,7,8,3,2] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

test_input = { "nums": [9,8,2,10,7] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

test_input = { "nums": [9,8,3,7,6] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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

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

test_input = { "nums": [9,8,9,5,7] }
assert my_solution.numberOfGoodPartitions(**test_input) == 4

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

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

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

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

test_input = { "nums": [10,5,6,2,8] }
assert my_solution.numberOfGoodPartitions(**test_input) == 16

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


find-common-elements-between-two-arrays

Find Common Elements Between Two Arrays

Prompt:
"""
给你两个下标从 0开始的整数数组nums1和nums2，它们分别含有 n和 m个元素。
请你计算以下两个数值：

统计0 <= i < n中的下标i，满足nums1[i]在 nums2中 至少出现了一次。
统计0 <= i < m中的下标i，满足nums2[i]在 nums1中 至少出现了一次。

请你返回一个长度为 2的整数数组answer，按顺序分别为以上两个数值。

示例 1：

输入：nums1 = [4,3,2,3,1], nums2 = [2,2,5,2,3,6]
输出：[3,4]
解释：分别计算两个数值：
- nums1 中下标为 1 ，2 和 3 的元素在 nums2 中至少出现了一次，所以第一个值为 3 。
- nums2 中下标为 0 ，1 ，3 和 4 的元素在 nums1 中至少出现了一次，所以第二个值为 4 。

示例 2：

输入：nums1 = [3,4,2,3], nums2 = [1,5]
输出：[0,0]
解释：两个数组中没有公共元素，所以两个值都为 0 。

提示：

n == nums1.length
m == nums2.length
1 <= n, m <= 100
1 <= nums1[i], nums2[i] <= 100
"""
class Solution:
    def findIntersectionValues(self, nums1: List[int], nums2: List[int]) -> List[int]:

给你两个下标从 0开始的整数数组nums1和nums2，它们分别含有 n和 m个元素。
请你计算以下两个数值：

统计0 <= i < n中的下标i，满足nums1[i]在 nums2中 至少出现了一次。
统计0 <= i < m中的下标i，满足nums2[i]在 nums1中 至少出现了一次。

请你返回一个长度为 2的整数数组answer，按顺序分别为以上两个数值。

示例 1：

输入：nums1 = [4,3,2,3,1], nums2 = [2,2,5,2,3,6]
输出：[3,4]
解释：分别计算两个数值：
- nums1 中下标为 1 ，2 和 3 的元素在 nums2 中至少出现了一次，所以第一个值为 3 。
- nums2 中下标为 0 ，1 ，3 和 4 的元素在 nums1 中至少出现了一次，所以第二个值为 4 。

示例 2：

输入：nums1 = [3,4,2,3], nums2 = [1,5]
输出：[0,0]
解释：两个数组中没有公共元素，所以两个值都为 0 。

提示：

n == nums1.length
m == nums2.length
1 <= n, m <= 100
1 <= nums1[i], nums2[i] <= 100

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

```


remove-adjacent-almost-equal-characters

Remove Adjacent Almost-Equal Characters

Prompt:
"""
给你一个下标从 0开始的字符串word。
一次操作中，你可以选择word中任意一个下标 i，将word[i] 修改成任意一个小写英文字母。
请你返回消除 word中所有相邻 近似相等字符的 最少操作次数。
两个字符a 和b如果满足a == b或者a 和b在字母表中是相邻的，那么我们称它们是 近似相等字符。

示例 1：

输入：word = "aaaaa"
输出：2
解释：我们将 word 变为 "acaca" ，该字符串没有相邻近似相等字符。
消除 word 中所有相邻近似相等字符最少需要 2 次操作。

示例 2：

输入：word = "abddez"
输出：2
解释：我们将 word 变为 "ybdoez" ，该字符串没有相邻近似相等字符。
消除 word 中所有相邻近似相等字符最少需要 2 次操作。
示例 3：

输入：word = "zyxyxyz"
输出：3
解释：我们将 word 变为 "zaxaxaz" ，该字符串没有相邻近似相等字符。
消除 word 中所有相邻近似相等字符最少需要 3 次操作

提示：

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

给你一个下标从 0开始的字符串word。
一次操作中，你可以选择word中任意一个下标 i，将word[i] 修改成任意一个小写英文字母。
请你返回消除 word中所有相邻 近似相等字符的 最少操作次数。
两个字符a 和b如果满足a == b或者a 和b在字母表中是相邻的，那么我们称它们是 近似相等字符。

示例 1：

输入：word = "aaaaa"
输出：2
解释：我们将 word 变为 "acaca" ，该字符串没有相邻近似相等字符。
消除 word 中所有相邻近似相等字符最少需要 2 次操作。

示例 2：

输入：word = "abddez"
输出：2
解释：我们将 word 变为 "ybdoez" ，该字符串没有相邻近似相等字符。
消除 word 中所有相邻近似相等字符最少需要 2 次操作。
示例 3：

输入：word = "zyxyxyz"
输出：3
解释：我们将 word 变为 "zaxaxaz" ，该字符串没有相邻近似相等字符。
消除 word 中所有相邻近似相等字符最少需要 3 次操作

提示：

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

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

```

my_solution = Solution()

test_input = { "word": "aaaaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abddez" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "zyxyxyz" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 3

test_input = { "word": "a" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "b" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "c" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "aa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "ba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "cb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "abb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "abc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "acb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "baa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bcb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bcc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "caa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "cba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ccb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ccc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aaaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aaab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aaac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aaba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aabb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aabc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aaca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aacb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aacc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "abba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "abcb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abcc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "acaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "acba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "accb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "accc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "baaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "baab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "baac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "baba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "babb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "babc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "baca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bacb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bacc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bbba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bbcb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbcc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bcba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bccb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bccc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "caaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "caab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "caac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "caba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1