find-missing-and-repeated-values

Find Missing and Repeated Values

Prompt:
"""
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b.
Return a 0-indexed integer array ans of size 2 where ans[0] equals to a and ans[1] equals to b.

Example 1:

Input: grid = [[1,3],[2,2]]
Output: [2,4]
Explanation: Number 2 is repeated and number 4 is missing so the answer is [2,4].

Example 2:

Input: grid = [[9,1,7],[8,9,2],[3,4,6]]
Output: [9,5]
Explanation: Number 9 is repeated and number 5 is missing so the answer is [9,5].

Constraints:

2 <= n == grid.length == grid[i].length <= 50
1 <= grid[i][j] <= n * n
For all x that 1 <= x <= n * n there is exactly one x that is not equal to any of the grid members.
For all x that 1 <= x <= n * n there is exactly one x that is equal to exactly two of the grid members.
For all x that 1 <= x <= n * n except two of them there is exatly one pair of i, j that 0 <= i, j <= n - 1 and grid[i][j] == x.
"""
class Solution:
    def findMissingAndRepeatedValues(self, grid: List[List[int]]) -> List[int]:

You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b.
Return a 0-indexed integer array ans of size 2 where ans[0] equals to a and ans[1] equals to b.

Example 1:

Input: grid = [[1,3],[2,2]]
Output: [2,4]
Explanation: Number 2 is repeated and number 4 is missing so the answer is [2,4].

Example 2:

Input: grid = [[9,1,7],[8,9,2],[3,4,6]]
Output: [9,5]
Explanation: Number 9 is repeated and number 5 is missing so the answer is [9,5].

Constraints:

2 <= n == grid.length == grid[i].length <= 50
1 <= grid[i][j] <= n * n
For all x that 1 <= x <= n * n there is exactly one x that is not equal to any of the grid members.
For all x that 1 <= x <= n * n there is exactly one x that is equal to exactly two of the grid members.
For all x that 1 <= x <= n * n except two of them there is exatly one pair of i, j that 0 <= i, j <= n - 1 and grid[i][j] == x.

Please complete the code below to solve above prblem:
```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:
"""
You are given an integer array nums of size n and a positive integer k.
Divide the array into one or more arrays of size 3 satisfying the following conditions:

Each element of nums should be in exactly one array.
The difference between any two elements in one array is less than or equal to k.

Return a 2D array containing all the arrays. If it is impossible to satisfy the conditions, return an empty array. And if there are multiple answers, return any of them.

Example 1:

Input: nums = [1,3,4,8,7,9,3,5,1], k = 2
Output: [[1,1,3],[3,4,5],[7,8,9]]
Explanation: We can divide the array into the following arrays: [1,1,3], [3,4,5] and [7,8,9].
The difference between any two elements in each array is less than or equal to 2.
Note that the order of elements is not important.

Example 2:

Input: nums = [1,3,3,2,7,3], k = 3
Output: []
Explanation: It is not possible to divide the array satisfying all the conditions.

Constraints:

n == nums.length
1 <= n <= 105
n is a multiple of 3.
1 <= nums[i] <= 105
1 <= k <= 105
"""
class Solution:
    def divideArray(self, nums: List[int], k: int) -> List[List[int]]:

You are given an integer array nums of size n and a positive integer k.
Divide the array into one or more arrays of size 3 satisfying the following conditions:

Each element of nums should be in exactly one array.
The difference between any two elements in one array is less than or equal to k.

Return a 2D array containing all the arrays. If it is impossible to satisfy the conditions, return an empty array. And if there are multiple answers, return any of them.

Example 1:

Input: nums = [1,3,4,8,7,9,3,5,1], k = 2
Output: [[1,1,3],[3,4,5],[7,8,9]]
Explanation: We can divide the array into the following arrays: [1,1,3], [3,4,5] and [7,8,9].
The difference between any two elements in each array is less than or equal to 2.
Note that the order of elements is not important.

Example 2:

Input: nums = [1,3,3,2,7,3], k = 3
Output: []
Explanation: It is not possible to divide the array satisfying all the conditions.

Constraints:

n == nums.length
1 <= n <= 105
n is a multiple of 3.
1 <= nums[i] <= 105
1 <= k <= 105

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed integer array nums having length n.
You are allowed to perform a special move any number of times (including zero) on nums. In one special move you perform the following steps in order:

Choose an index i in the range [0, n - 1], and a positive integer x.
Add |nums[i] - x| to the total cost.
Change the value of nums[i] to x.

A palindromic number is a positive integer that remains the same when its digits are reversed. For example, 121, 2552 and 65756 are palindromic numbers whereas 24, 46, 235 are not palindromic numbers.
An array is considered equalindromic if all the elements in the array are equal to an integer y, where y is a palindromic number less than 109.
Return an integer denoting the minimum possible total cost to make nums equalindromic by performing any number of special moves.

Example 1:

Input: nums = [1,2,3,4,5]
Output: 6
Explanation: We can make the array equalindromic by changing all elements to 3 which is a palindromic number. The cost of changing the array to [3,3,3,3,3] using 4 special moves is given by |1 - 3| + |2 - 3| + |4 - 3| + |5 - 3| = 6.
It can be shown that changing all elements to any palindromic number other than 3 cannot be achieved at a lower cost.

Example 2:

Input: nums = [10,12,13,14,15]
Output: 11
Explanation: We can make the array equalindromic by changing all elements to 11 which is a palindromic number. The cost of changing the array to [11,11,11,11,11] using 5 special moves is given by |10 - 11| + |12 - 11| + |13 - 11| + |14 - 11| + |15 - 11| = 11.
It can be shown that changing all elements to any palindromic number other than 11 cannot be achieved at a lower cost.

Example 3:

Input: nums = [22,33,22,33,22]
Output: 22
Explanation: We can make the array equalindromic by changing all elements to 22 which is a palindromic number. The cost of changing the array to [22,22,22,22,22] using 2 special moves is given by |33 - 22| + |33 - 22| = 22.
It can be shown that changing all elements to any palindromic number other than 22 cannot be achieved at a lower cost.

Constraints:

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

You are given a 0-indexed integer array nums having length n.
You are allowed to perform a special move any number of times (including zero) on nums. In one special move you perform the following steps in order:

Choose an index i in the range [0, n - 1], and a positive integer x.
Add |nums[i] - x| to the total cost.
Change the value of nums[i] to x.

A palindromic number is a positive integer that remains the same when its digits are reversed. For example, 121, 2552 and 65756 are palindromic numbers whereas 24, 46, 235 are not palindromic numbers.
An array is considered equalindromic if all the elements in the array are equal to an integer y, where y is a palindromic number less than 109.
Return an integer denoting the minimum possible total cost to make nums equalindromic by performing any number of special moves.

Example 1:

Input: nums = [1,2,3,4,5]
Output: 6
Explanation: We can make the array equalindromic by changing all elements to 3 which is a palindromic number. The cost of changing the array to [3,3,3,3,3] using 4 special moves is given by |1 - 3| + |2 - 3| + |4 - 3| + |5 - 3| = 6.
It can be shown that changing all elements to any palindromic number other than 3 cannot be achieved at a lower cost.

Example 2:

Input: nums = [10,12,13,14,15]
Output: 11
Explanation: We can make the array equalindromic by changing all elements to 11 which is a palindromic number. The cost of changing the array to [11,11,11,11,11] using 5 special moves is given by |10 - 11| + |12 - 11| + |13 - 11| + |14 - 11| + |15 - 11| = 11.
It can be shown that changing all elements to any palindromic number other than 11 cannot be achieved at a lower cost.

Example 3:

Input: nums = [22,33,22,33,22]
Output: 22
Explanation: We can make the array equalindromic by changing all elements to 22 which is a palindromic number. The cost of changing the array to [22,22,22,22,22] using 2 special moves is given by |33 - 22| + |33 - 22| = 22.
It can be shown that changing all elements to any palindromic number other than 22 cannot be achieved at a lower cost.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed integer array nums and an integer k.
You can perform the following operation on the array at most k times:

Choose any index i from the array and increase or decrease nums[i] by 1.

The score of the final array is the frequency of the most frequent element in the array.
Return the maximum score you can achieve.
The frequency of an element is the number of occurences of that element in the array.

Example 1:

Input: nums = [1,2,6,4], k = 3
Output: 3
Explanation: We can do the following operations on the array:
- Choose i = 0, and increase the value of nums[0] by 1. The resulting array is [2,2,6,4].
- Choose i = 3, and decrease the value of nums[3] by 1. The resulting array is [2,2,6,3].
- Choose i = 3, and decrease the value of nums[3] by 1. The resulting array is [2,2,6,2].
The element 2 is the most frequent in the final array so our score is 3.
It can be shown that we cannot achieve a better score.

Example 2:

Input: nums = [1,4,4,2,4], k = 0
Output: 3
Explanation: We cannot apply any operations so our score will be the frequency of the most frequent element in the original array, which is 3.

Constraints:

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

You are given a 0-indexed integer array nums and an integer k.
You can perform the following operation on the array at most k times:

Choose any index i from the array and increase or decrease nums[i] by 1.

The score of the final array is the frequency of the most frequent element in the array.
Return the maximum score you can achieve.
The frequency of an element is the number of occurences of that element in the array.

Example 1:

Input: nums = [1,2,6,4], k = 3
Output: 3
Explanation: We can do the following operations on the array:
- Choose i = 0, and increase the value of nums[0] by 1. The resulting array is [2,2,6,4].
- Choose i = 3, and decrease the value of nums[3] by 1. The resulting array is [2,2,6,3].
- Choose i = 3, and decrease the value of nums[3] by 1. The resulting array is [2,2,6,2].
The element 2 is the most frequent in the final array so our score is 3.
It can be shown that we cannot achieve a better score.

Example 2:

Input: nums = [1,4,4,2,4], k = 0
Output: 3
Explanation: We cannot apply any operations so our score will be the frequency of the most frequent element in the original array, which is 3.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices.
Your task is to test each device i in order from 0 to n - 1, by performing the following test operations:

If batteryPercentages[i] is greater than 0:

Increment the count of tested devices.
Decrease the battery percentage of all devices with indices j in the range [i + 1, n - 1] by 1, ensuring their battery percentage never goes below 0, i.e, batteryPercentages[j] = max(0, batteryPercentages[j] - 1).
Move to the next device.

Otherwise, move to the next device without performing any test.

Return an integer denoting the number of devices that will be tested after performing the test operations in order.

Example 1:

Input: batteryPercentages = [1,1,2,1,3]
Output: 3
Explanation: Performing the test operations in order starting from device 0:
At device 0, batteryPercentages[0] > 0, so there is now 1 tested device, and batteryPercentages becomes [1,0,1,0,2].
At device 1, batteryPercentages[1] == 0, so we move to the next device without testing.
At device 2, batteryPercentages[2] > 0, so there are now 2 tested devices, and batteryPercentages becomes [1,0,1,0,1].
At device 3, batteryPercentages[3] == 0, so we move to the next device without testing.
At device 4, batteryPercentages[4] > 0, so there are now 3 tested devices, and batteryPercentages stays the same.
So, the answer is 3.

Example 2:

Input: batteryPercentages = [0,1,2]
Output: 2
Explanation: Performing the test operations in order starting from device 0:
At device 0, batteryPercentages[0] == 0, so we move to the next device without testing.
At device 1, batteryPercentages[1] > 0, so there is now 1 tested device, and batteryPercentages becomes [0,1,1].
At device 2, batteryPercentages[2] > 0, so there are now 2 tested devices, and batteryPercentages stays the same.
So, the answer is 2.

Constraints:

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

You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices.
Your task is to test each device i in order from 0 to n - 1, by performing the following test operations:

If batteryPercentages[i] is greater than 0:

Increment the count of tested devices.
Decrease the battery percentage of all devices with indices j in the range [i + 1, n - 1] by 1, ensuring their battery percentage never goes below 0, i.e, batteryPercentages[j] = max(0, batteryPercentages[j] - 1).
Move to the next device.

Otherwise, move to the next device without performing any test.

Return an integer denoting the number of devices that will be tested after performing the test operations in order.

Example 1:

Input: batteryPercentages = [1,1,2,1,3]
Output: 3
Explanation: Performing the test operations in order starting from device 0:
At device 0, batteryPercentages[0] > 0, so there is now 1 tested device, and batteryPercentages becomes [1,0,1,0,2].
At device 1, batteryPercentages[1] == 0, so we move to the next device without testing.
At device 2, batteryPercentages[2] > 0, so there are now 2 tested devices, and batteryPercentages becomes [1,0,1,0,1].
At device 3, batteryPercentages[3] == 0, so we move to the next device without testing.
At device 4, batteryPercentages[4] > 0, so there are now 3 tested devices, and batteryPercentages stays the same.
So, the answer is 3.

Example 2:

Input: batteryPercentages = [0,1,2]
Output: 2
Explanation: Performing the test operations in order starting from device 0:
At device 0, batteryPercentages[0] == 0, so we move to the next device without testing.
At device 1, batteryPercentages[1] > 0, so there is now 1 tested device, and batteryPercentages becomes [0,1,1].
At device 2, batteryPercentages[2] > 0, so there are now 2 tested devices, and batteryPercentages stays the same.
So, the answer is 2.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed 2D array variables where variables[i] = [ai, bi, ci, mi], and an integer target.
An index i is good if the following formula holds:

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

Return an array consisting of good indices in any order.

Example 1:

Input: variables = [[2,3,3,10],[3,3,3,1],[6,1,1,4]], target = 2
Output: [0,2]
Explanation: For each index i in the variables array:
1) For the index 0, variables[0] = [2,3,3,10], (23 % 10)3 % 10 = 2.
2) For the index 1, variables[1] = [3,3,3,1], (33 % 10)3 % 1 = 0.
3) For the index 2, variables[2] = [6,1,1,4], (61 % 10)1 % 4 = 2.
Therefore we return [0,2] as the answer.

Example 2:

Input: variables = [[39,3,1000,1000]], target = 17
Output: []
Explanation: For each index i in the variables array:
1) For the index 0, variables[0] = [39,3,1000,1000], (393 % 10)1000 % 1000 = 1.
Therefore we return [] as the answer.

Constraints:

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

You are given a 0-indexed 2D array variables where variables[i] = [ai, bi, ci, mi], and an integer target.
An index i is good if the following formula holds:

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

Return an array consisting of good indices in any order.

Example 1:

Input: variables = [[2,3,3,10],[3,3,3,1],[6,1,1,4]], target = 2
Output: [0,2]
Explanation: For each index i in the variables array:
1) For the index 0, variables[0] = [2,3,3,10], (23 % 10)3 % 10 = 2.
2) For the index 1, variables[1] = [3,3,3,1], (33 % 10)3 % 1 = 0.
3) For the index 2, variables[2] = [6,1,1,4], (61 % 10)1 % 4 = 2.
Therefore we return [0,2] as the answer.

Example 2:

Input: variables = [[39,3,1000,1000]], target = 17
Output: []
Explanation: For each index i in the variables array:
1) For the index 0, variables[0] = [39,3,1000,1000], (393 % 10)1000 % 1000 = 1.
Therefore we return [] as the answer.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given an integer array nums and a positive integer k.
Return the number of subarrays where the maximum element of nums appears at least k times in that subarray.
A subarray is a contiguous sequence of elements within an array.

Example 1:

Input: nums = [1,3,2,3,3], k = 2
Output: 6
Explanation: The subarrays that contain the element 3 at least 2 times are: [1,3,2,3], [1,3,2,3,3], [3,2,3], [3,2,3,3], [2,3,3] and [3,3].

Example 2:

Input: nums = [1,4,2,1], k = 3
Output: 0
Explanation: No subarray contains the element 4 at least 3 times.

Constraints:

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

You are given an integer array nums and a positive integer k.
Return the number of subarrays where the maximum element of nums appears at least k times in that subarray.
A subarray is a contiguous sequence of elements within an array.

Example 1:

Input: nums = [1,3,2,3,3], k = 2
Output: 6
Explanation: The subarrays that contain the element 3 at least 2 times are: [1,3,2,3], [1,3,2,3,3], [3,2,3], [3,2,3,3], [2,3,3] and [3,3].

Example 2:

Input: nums = [1,4,2,1], k = 3
Output: 0
Explanation: No subarray contains the element 4 at least 3 times.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed array nums consisting of positive integers.
A partition of an array into one or more contiguous subarrays is called good if no two subarrays contain the same number.
Return the total number of good partitions of nums.
Since the answer may be large, return it modulo 109 + 7.

Example 1:

Input: nums = [1,2,3,4]
Output: 8
Explanation: The 8 possible good partitions are: ([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]), and ([1,2,3,4]).

Example 2:

Input: nums = [1,1,1,1]
Output: 1
Explanation: The only possible good partition is: ([1,1,1,1]).

Example 3:

Input: nums = [1,2,1,3]
Output: 2
Explanation: The 2 possible good partitions are: ([1,2,1], [3]) and ([1,2,1,3]).

Constraints:

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

You are given a 0-indexed array nums consisting of positive integers.
A partition of an array into one or more contiguous subarrays is called good if no two subarrays contain the same number.
Return the total number of good partitions of nums.
Since the answer may be large, return it modulo 109 + 7.

Example 1:

Input: nums = [1,2,3,4]
Output: 8
Explanation: The 8 possible good partitions are: ([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]), and ([1,2,3,4]).

Example 2:

Input: nums = [1,1,1,1]
Output: 1
Explanation: The only possible good partition is: ([1,1,1,1]).

Example 3:

Input: nums = [1,2,1,3]
Output: 2
Explanation: The 2 possible good partitions are: ([1,2,1], [3]) and ([1,2,1,3]).

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively.
Consider calculating the following values:

The number of indices i such that 0 <= i < n and nums1[i] occurs at least once in nums2.
The number of indices i such that 0 <= i < m and nums2[i] occurs at least once in nums1.

Return an integer array answer of size 2 containing the two values in the above order.

Example 1:

Input: nums1 = [4,3,2,3,1], nums2 = [2,2,5,2,3,6]
Output: [3,4]
Explanation: We calculate the values as follows:
- The elements at indices 1, 2, and 3 in nums1 occur at least once in nums2. So the first value is 3.
- The elements at indices 0, 1, 3, and 4 in nums2 occur at least once in nums1. So the second value is 4.

Example 2:

Input: nums1 = [3,4,2,3], nums2 = [1,5]
Output: [0,0]
Explanation: There are no common elements between the two arrays, so the two values will be 0.

Constraints:

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

You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively.
Consider calculating the following values:

The number of indices i such that 0 <= i < n and nums1[i] occurs at least once in nums2.
The number of indices i such that 0 <= i < m and nums2[i] occurs at least once in nums1.

Return an integer array answer of size 2 containing the two values in the above order.

Example 1:

Input: nums1 = [4,3,2,3,1], nums2 = [2,2,5,2,3,6]
Output: [3,4]
Explanation: We calculate the values as follows:
- The elements at indices 1, 2, and 3 in nums1 occur at least once in nums2. So the first value is 3.
- The elements at indices 0, 1, 3, and 4 in nums2 occur at least once in nums1. So the second value is 4.

Example 2:

Input: nums1 = [3,4,2,3], nums2 = [1,5]
Output: [0,0]
Explanation: There are no common elements between the two arrays, so the two values will be 0.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed string word.
In one operation, you can pick any index i of word and change word[i] to any lowercase English letter.
Return the minimum number of operations needed to remove all adjacent almost-equal characters from word.
Two characters a and b are almost-equal if a == b or a and b are adjacent in the alphabet.

Example 1:

Input: word = "aaaaa"
Output: 2
Explanation: We can change word into "acaca" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.

Example 2:

Input: word = "abddez"
Output: 2
Explanation: We can change word into "ybdoez" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.
Example 3:

Input: word = "zyxyxyz"
Output: 3
Explanation: We can change word into "zaxaxaz" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 3.

Constraints:

1 <= word.length <= 100
word consists only of lowercase English letters.
"""
class Solution:
    def removeAlmostEqualCharacters(self, word: str) -> int:

You are given a 0-indexed string word.
In one operation, you can pick any index i of word and change word[i] to any lowercase English letter.
Return the minimum number of operations needed to remove all adjacent almost-equal characters from word.
Two characters a and b are almost-equal if a == b or a and b are adjacent in the alphabet.

Example 1:

Input: word = "aaaaa"
Output: 2
Explanation: We can change word into "acaca" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.

Example 2:

Input: word = "abddez"
Output: 2
Explanation: We can change word into "ybdoez" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.
Example 3:

Input: word = "zyxyxyz"
Output: 3
Explanation: We can change word into "zaxaxaz" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 3.

Constraints:

1 <= word.length <= 100
word consists only of lowercase English letters.

Please complete the code below to solve above prblem:
```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