maximize-value-of-function-in-a-ball-passing-game

Maximize Value of Function in a Ball Passing Game

Prompt:
"""
给你一个长度为 n 下标从 0 开始的整数数组 receiver 和一个整数 k 。

总共有 n 名玩家，玩家 编号 互不相同，且为 [0, n - 1] 中的整数。这些玩家玩一个传球游戏，receiver[i] 表示编号为 i 的玩家会传球给编号为 receiver[i] 的玩家。玩家可以传球给自己，也就是说 receiver[i] 可能等于 i 。

你需要从 n 名玩家中选择一名玩家作为游戏开始时唯一手中有球的玩家，球会被传 恰好 k 次。

如果选择编号为 x 的玩家作为开始玩家，定义函数 f(x) 表示从编号为 x 的玩家开始，k 次传球内所有接触过球玩家的编号之 和 ，如果有玩家多次触球，则 累加多次 。换句话说， f(x) = x + receiver[x] + receiver[receiver[x]] + ... + receiver(k)[x] 。

你的任务时选择开始玩家 x ，目的是 最大化 f(x) 。

请你返回函数的 最大值 。

注意：receiver 可能含有重复元素。

示例 1：

传递次数 传球者编号 接球者编号 x + 所有接球者编号       2 1 2 1 3 2 1 0 3 3 0 2 5 4 2 1 6

输入：receiver = [2,0,1], k = 4
输出：6
解释：上表展示了从编号为 x = 2 开始的游戏过程。
从表中可知，f(2) 等于 6 。
6 是能得到最大的函数值。
所以输出为 6 。

示例 2：

传递次数 传球者编号 接球者编号 x + 所有接球者编号       4 1 4 3 7 2 3 2 9 3 2 1 10

输入：receiver = [1,1,1,2,3], k = 3
输出：10
解释：上表展示了从编号为 x = 4 开始的游戏过程。
从表中可知，f(4) 等于 10 。
10 是能得到最大的函数值。
所以输出为 10 。

提示：

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

给你一个长度为 n 下标从 0 开始的整数数组 receiver 和一个整数 k 。

总共有 n 名玩家，玩家 编号 互不相同，且为 [0, n - 1] 中的整数。这些玩家玩一个传球游戏，receiver[i] 表示编号为 i 的玩家会传球给编号为 receiver[i] 的玩家。玩家可以传球给自己，也就是说 receiver[i] 可能等于 i 。

你需要从 n 名玩家中选择一名玩家作为游戏开始时唯一手中有球的玩家，球会被传 恰好 k 次。

如果选择编号为 x 的玩家作为开始玩家，定义函数 f(x) 表示从编号为 x 的玩家开始，k 次传球内所有接触过球玩家的编号之 和 ，如果有玩家多次触球，则 累加多次 。换句话说， f(x) = x + receiver[x] + receiver[receiver[x]] + ... + receiver(k)[x] 。

你的任务时选择开始玩家 x ，目的是 最大化 f(x) 。

请你返回函数的 最大值 。

注意：receiver 可能含有重复元素。

示例 1：

传递次数 传球者编号 接球者编号 x + 所有接球者编号       2 1 2 1 3 2 1 0 3 3 0 2 5 4 2 1 6

输入：receiver = [2,0,1], k = 4
输出：6
解释：上表展示了从编号为 x = 2 开始的游戏过程。
从表中可知，f(2) 等于 6 。
6 是能得到最大的函数值。
所以输出为 6 。

示例 2：

传递次数 传球者编号 接球者编号 x + 所有接球者编号       4 1 4 3 7 2 3 2 9 3 2 1 10

输入：receiver = [1,1,1,2,3], k = 3
输出：10
解释：上表展示了从编号为 x = 4 开始的游戏过程。
从表中可知，f(4) 等于 10 。
10 是能得到最大的函数值。
所以输出为 10 。

提示：

 * 1 <= receiver.length == n <= 105
 * 0 <= receiver[i] <= n - 1
 * 1 <= k <= 1010

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

```

my_solution = Solution()

test_input = { "receiver": [2,0,1], "k": 4 }
assert my_solution.getMaxFunctionValue(**test_input) == 6

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

test_input = { "receiver": [0], "k": 1 }
assert my_solution.getMaxFunctionValue(**test_input) == 0

test_input = { "receiver": [0], "k": 2 }
assert my_solution.getMaxFunctionValue(**test_input) == 0

test_input = { "receiver": [0], "k": 3 }
assert my_solution.getMaxFunctionValue(**test_input) == 0

test_input = { "receiver": [0], "k": 100 }
assert my_solution.getMaxFunctionValue(**test_input) == 0

test_input = { "receiver": [0,0], "k": 1 }
assert my_solution.getMaxFunctionValue(**test_input) == 1

test_input = { "receiver": [0,0], "k": 7 }
assert my_solution.getMaxFunctionValue(**test_input) == 1

test_input = { "receiver": [0,0], "k": 10 }
assert my_solution.getMaxFunctionValue(**test_input) == 1

test_input = { "receiver": [0,0], "k": 13 }
assert my_solution.getMaxFunctionValue(**test_input) == 1

test_input = { "receiver": [0,0], "k": 16 }
assert my_solution.getMaxFunctionValue(**test_input) == 1

test_input = { "receiver": [0,1], "k": 1 }
assert my_solution.getMaxFunctionValue(**test_input) == 2

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

test_input = { "receiver": [0,1], "k": 5 }
assert my_solution.getMaxFunctionValue(**test_input) == 6

test_input = { "receiver": [0,1], "k": 8 }
assert my_solution.getMaxFunctionValue(**test_input) == 9

test_input = { "receiver": [0,1], "k": 13 }
assert my_solution.getMaxFunctionValue(**test_input) == 14

test_input = { "receiver": [0,1], "k": 14 }
assert my_solution.getMaxFunctionValue(**test_input) == 15

test_input = { "receiver": [0,1], "k": 15 }
assert my_solution.getMaxFunctionValue(**test_input) == 16

test_input = { "receiver": [1,0], "k": 5 }
assert my_solution.getMaxFunctionValue(**test_input) == 3

test_input = { "receiver": [1,0], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 4

test_input = { "receiver": [1,0], "k": 7 }
assert my_solution.getMaxFunctionValue(**test_input) == 4

test_input = { "receiver": [1,0], "k": 10 }
assert my_solution.getMaxFunctionValue(**test_input) == 6

test_input = { "receiver": [1,0], "k": 12 }
assert my_solution.getMaxFunctionValue(**test_input) == 7

test_input = { "receiver": [1,0], "k": 14 }
assert my_solution.getMaxFunctionValue(**test_input) == 8

test_input = { "receiver": [1,0], "k": 57 }
assert my_solution.getMaxFunctionValue(**test_input) == 29

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

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

test_input = { "receiver": [1,1], "k": 7 }
assert my_solution.getMaxFunctionValue(**test_input) == 8

test_input = { "receiver": [0,0,0], "k": 1 }
assert my_solution.getMaxFunctionValue(**test_input) == 2

test_input = { "receiver": [0,0,0], "k": 4 }
assert my_solution.getMaxFunctionValue(**test_input) == 2

test_input = { "receiver": [0,0,0], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 2

test_input = { "receiver": [0,0,0], "k": 10 }
assert my_solution.getMaxFunctionValue(**test_input) == 2

test_input = { "receiver": [0,0,1], "k": 3 }
assert my_solution.getMaxFunctionValue(**test_input) == 3

test_input = { "receiver": [0,0,1], "k": 9 }
assert my_solution.getMaxFunctionValue(**test_input) == 3

test_input = { "receiver": [0,0,2], "k": 11 }
assert my_solution.getMaxFunctionValue(**test_input) == 24

test_input = { "receiver": [0,0,2], "k": 14 }
assert my_solution.getMaxFunctionValue(**test_input) == 30

test_input = { "receiver": [0,0,2], "k": 82 }
assert my_solution.getMaxFunctionValue(**test_input) == 166

test_input = { "receiver": [0,1,0], "k": 5 }
assert my_solution.getMaxFunctionValue(**test_input) == 6

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

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

test_input = { "receiver": [0,1,2], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 14

test_input = { "receiver": [1,0,0], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 5

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

test_input = { "receiver": [1,0,2], "k": 10 }
assert my_solution.getMaxFunctionValue(**test_input) == 22

test_input = { "receiver": [1,1,1], "k": 4 }
assert my_solution.getMaxFunctionValue(**test_input) == 6

test_input = { "receiver": [1,1,1], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 8

test_input = { "receiver": [1,1,2], "k": 8 }
assert my_solution.getMaxFunctionValue(**test_input) == 18

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

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

test_input = { "receiver": [1,2,1], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 11

test_input = { "receiver": [1,2,2], "k": 7 }
assert my_solution.getMaxFunctionValue(**test_input) == 16

test_input = { "receiver": [2,0,2], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 14

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

test_input = { "receiver": [2,1,0], "k": 8 }
assert my_solution.getMaxFunctionValue(**test_input) == 10

test_input = { "receiver": [2,1,0], "k": 10 }
assert my_solution.getMaxFunctionValue(**test_input) == 12

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

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

test_input = { "receiver": [2,1,2], "k": 15 }
assert my_solution.getMaxFunctionValue(**test_input) == 32

test_input = { "receiver": [2,2,0], "k": 4 }
assert my_solution.getMaxFunctionValue(**test_input) == 6

test_input = { "receiver": [2,2,0], "k": 9 }
assert my_solution.getMaxFunctionValue(**test_input) == 11

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

test_input = { "receiver": [2,2,1], "k": 10 }
assert my_solution.getMaxFunctionValue(**test_input) == 17

test_input = { "receiver": [2,2,2], "k": 15 }
assert my_solution.getMaxFunctionValue(**test_input) == 32

test_input = { "receiver": [0,0,3,0], "k": 4 }
assert my_solution.getMaxFunctionValue(**test_input) == 5

test_input = { "receiver": [0,1,0,1], "k": 11 }
assert my_solution.getMaxFunctionValue(**test_input) == 14

test_input = { "receiver": [0,1,1,3], "k": 5 }
assert my_solution.getMaxFunctionValue(**test_input) == 18

test_input = { "receiver": [0,2,1,3], "k": 5 }
assert my_solution.getMaxFunctionValue(**test_input) == 18

test_input = { "receiver": [0,2,3,1], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 15

test_input = { "receiver": [0,2,3,3], "k": 8 }
assert my_solution.getMaxFunctionValue(**test_input) == 27

test_input = { "receiver": [0,2,3,3], "k": 15 }
assert my_solution.getMaxFunctionValue(**test_input) == 48

test_input = { "receiver": [0,3,3,0], "k": 10 }
assert my_solution.getMaxFunctionValue(**test_input) == 5

test_input = { "receiver": [1,0,0,2], "k": 9 }
assert my_solution.getMaxFunctionValue(**test_input) == 9

test_input = { "receiver": [1,0,1,2], "k": 15 }
assert my_solution.getMaxFunctionValue(**test_input) == 12

test_input = { "receiver": [1,0,3,1], "k": 6 }
assert my_solution.getMaxFunctionValue(**test_input) == 8

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

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

test_input = { "receiver": [1,1,0,3], "k": 3 }
assert my_solution.getMaxFunctionValue(**test_input) == 12

test_input = { "receiver": [1,1,1,3], "k": 7 }
assert my_solution.getMaxFunctionValue(**test_input) == 24

test_input = { "receiver": [1,2,0,0], "k": 14 }
assert my_solution.getMaxFunctionValue(**test_input) == 16

test_input = { "receiver": [1,2,0,1], "k": 5 }
assert my_solution.getMaxFunctionValue(**test_input) == 9

test_input = { "receiver": [1,2,3,1], "k": 47 }
assert my_solution.getMaxFunctionValue(**test_input) == 96

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

test_input = { "receiver": [1,3,3,0], "k": 7 }
assert my_solution.getMaxFunctionValue(**test_input) == 13

test_input = { "receiver": [2,0,0,1], "k": 9 }
assert my_solution.getMaxFunctionValue(**test_input) == 12

test_input = { "receiver": [2,0,0,2], "k": 12 }
assert my_solution.getMaxFunctionValue(**test_input) == 15

test_input = { "receiver": [2,0,2,0], "k": 5 }
assert my_solution.getMaxFunctionValue(**test_input) == 12

test_input = { "receiver": [2,1,0,0], "k": 8 }
assert my_solution.getMaxFunctionValue(**test_input) == 11

test_input = { "receiver": [2,1,0,1], "k": 97 }
assert my_solution.getMaxFunctionValue(**test_input) == 100

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

test_input = { "receiver": [2,2,3,2], "k": 8 }
assert my_solution.getMaxFunctionValue(**test_input) == 23

test_input = { "receiver": [2,3,2,1], "k": 56 }
assert my_solution.getMaxFunctionValue(**test_input) == 115

test_input = { "receiver": [2,3,3,1], "k": 15 }
assert my_solution.getMaxFunctionValue(**test_input) == 33

test_input = { "receiver": [2,3,3,3], "k": 2 }
assert my_solution.getMaxFunctionValue(**test_input) == 9

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

test_input = { "receiver": [3,0,0,2], "k": 85 }
assert my_solution.getMaxFunctionValue(**test_input) == 145

test_input = { "receiver": [3,0,1,3], "k": 9 }
assert my_solution.getMaxFunctionValue(**test_input) == 30

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

test_input = { "receiver": [3,1,2,0], "k": 60 }
assert my_solution.getMaxFunctionValue(**test_input) == 122

test_input = { "receiver": [3,2,0,3], "k": 12 }
assert my_solution.getMaxFunctionValue(**test_input) == 39

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


check-if-a-string-is-an-acronym-of-words

Check if a String Is an Acronym of Words

Prompt:
"""
给你一个字符串数组 words 和一个字符串 s ，请你判断 s 是不是 words 的 首字母缩略词 。

如果可以按顺序串联 words 中每个字符串的第一个字符形成字符串 s ，则认为 s 是 words 的首字母缩略词。例如，"ab" 可以由 ["apple", "banana"] 形成，但是无法从 ["bear", "aardvark"] 形成。

如果 s 是 words 的首字母缩略词，返回 true ；否则，返回 false 。

示例 1：

输入：words = ["alice","bob","charlie"], s = "abc"
输出：true
解释：words 中 "alice"、"bob" 和 "charlie" 的第一个字符分别是 'a'、'b' 和 'c'。因此，s = "abc" 是首字母缩略词。

示例 2：

输入：words = ["an","apple"], s = "a"
输出：false
解释：words 中 "an" 和 "apple" 的第一个字符分别是 'a' 和 'a'。
串联这些字符形成的首字母缩略词是 "aa" 。
因此，s = "a" 不是首字母缩略词。

示例 3：

输入：words = ["never","gonna","give","up","on","you"], s = "ngguoy"
输出：true
解释：串联数组 words 中每个字符串的第一个字符，得到字符串 "ngguoy" 。
因此，s = "ngguoy" 是首字母缩略词。

提示：

 * 1 <= words.length <= 100
 * 1 <= words[i].length <= 10
 * 1 <= s.length <= 100
 * words[i] 和 s 由小写英文字母组成
"""
class Solution:
    def isAcronym(self, words: List[str], s: str) -> bool:

给你一个字符串数组 words 和一个字符串 s ，请你判断 s 是不是 words 的 首字母缩略词 。

如果可以按顺序串联 words 中每个字符串的第一个字符形成字符串 s ，则认为 s 是 words 的首字母缩略词。例如，"ab" 可以由 ["apple", "banana"] 形成，但是无法从 ["bear", "aardvark"] 形成。

如果 s 是 words 的首字母缩略词，返回 true ；否则，返回 false 。

示例 1：

输入：words = ["alice","bob","charlie"], s = "abc"
输出：true
解释：words 中 "alice"、"bob" 和 "charlie" 的第一个字符分别是 'a'、'b' 和 'c'。因此，s = "abc" 是首字母缩略词。

示例 2：

输入：words = ["an","apple"], s = "a"
输出：false
解释：words 中 "an" 和 "apple" 的第一个字符分别是 'a' 和 'a'。
串联这些字符形成的首字母缩略词是 "aa" 。
因此，s = "a" 不是首字母缩略词。

示例 3：

输入：words = ["never","gonna","give","up","on","you"], s = "ngguoy"
输出：true
解释：串联数组 words 中每个字符串的第一个字符，得到字符串 "ngguoy" 。
因此，s = "ngguoy" 是首字母缩略词。

提示：

 * 1 <= words.length <= 100
 * 1 <= words[i].length <= 10
 * 1 <= s.length <= 100
 * words[i] 和 s 由小写英文字母组成

请完成下面的代码来解决上述问题:
```python
class Solution:
    def isAcronym(self, words: List[str], s: str) -> bool:

```

my_solution = Solution()

test_input = { "words": ["an","apple"], "s": "a" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["alice","bob","charlie"], "s": "abc" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["never","gonna","give","up","on","you"], "s": "ngguoy" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["ad","uadhrwxki"], "s": "au" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["afqcpzsx","icenu"], "s": "yi" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["afkc","icxufam"], "s": "ai" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["ahbibag","aoximesw"], "s": "aa" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["auqoc","koioxa"], "s": "ak" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["b","x"], "s": "bx" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["c","df"], "s": "bd" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["dv","g"], "s": "sg" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["dvn","acafe"], "s": "dp" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["bpctc","kaqquqbpmw"], "s": "bk" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["c","evlvvhrsqa"], "s": "ce" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["dwrvgkxdtm","wy"], "s": "hw" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["eceekigel","gmgdfvsrkw"], "s": "wg" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["cfsrsyt","md"], "s": "cm" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["envpklvi","jpymde"], "s": "en" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["espleklys","dg"], "s": "ea" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["euptjhixnu","fwci"], "s": "kf" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["ddnlfpvy","exs"], "s": "de" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["deacf","hldiauk"], "s": "dh" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["dllcn","tnzrnzypg"], "s": "dt" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["dmekslxlpo","wqdgxqwdk"], "s": "dw" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["eyzywjsxza","jxeimcc"], "s": "ex" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["f","oylvtltvo"], "s": "ho" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["eo","e"], "s": "ee" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["eucvcqdgg","qtdwhygerb"], "s": "eq" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["fnpow","ysqwqli"], "s": "jy" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["gpqyvv","kihi"], "s": "ik" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["exrgiw","irexgmrl"], "s": "ei" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["ez","acnmits"], "s": "ea" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["fvkekkv","jfbv"], "s": "fj" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["kncge","nje"], "s": "kw" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["fyocwzlz","lz"], "s": "fl" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["mnh","clep"], "s": "pc" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["mnpdwq","hziusbxr"], "s": "mg" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["g","r"], "s": "gr" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["n","fddigeie"], "s": "hf" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["gle","irt"], "s": "gi" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["h","xhtkcj"], "s": "hx" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["n","ityua"], "s": "ei" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["nmxysdim","xnpqsauh"], "s": "ne" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["ovdhflcck","ndd"], "s": "oi" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["piiyodecdf","wdwfxsjfou"], "s": "pp" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["hdmwkr","jfrqh"], "s": "hj" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["hflf","fvnotmdcpw"], "s": "hf" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["hnwphhozqw","cfhsjlqj"], "s": "hc" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["pxcsaaa","lrvxsc"], "s": "pz" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["htlsq","y"], "s": "hy" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["iakfeop","pd"], "s": "ip" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["qir","qyyzmntl"], "s": "qa" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["iakfmr","gzggxzwor"], "s": "ig" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["jna","rjdbu"], "s": "jr" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["qunqyc","ouzjotitvn"], "s": "co" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["rdednrsn","yfrgdeapme"], "s": "ny" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["rtnbfaemv","kgpcwaoik"], "s": "rf" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["s","n"], "s": "sx" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["siiyqtkyis","mogzgabcgk"], "s": "fm" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["tit","pmuqzrs"], "s": "tz" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["uip","hhstwupgg"], "s": "eh" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["uyj","jlfnksqlt"], "s": "ur" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["kabfejv","g"], "s": "kg" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["w","eshensjifo"], "s": "ez" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["khhhdsaevp","dnod"], "s": "kd" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["wefmc","tmunsmg"], "s": "jt" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["wo","jhaabx"], "s": "wx" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["kltil","mubemf"], "s": "km" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["kxkvhylsh","gyshntskq"], "s": "kg" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["wseopbedw","iihrgujev"], "s": "wq" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["kzxp","fy"], "s": "kf" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["wvdx","jerzn"], "s": "cj" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["y","qppnclhhbd"], "s": "mq" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["yegnsnddq","kusrkz"], "s": "bk" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["couqsa","sncuru","jhgxpxipg"], "s": "csa" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["csm","hexhvojfj","l"], "s": "chh" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["lbor","zx"], "s": "lz" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["losinu","ptsjoihvj"], "s": "lp" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["maczdfm","ywj"], "s": "my" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["d","geviina","tyljs"], "s": "dvt" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["mammhva","igyzbwpj"], "s": "mi" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["ecmlkida","vrjwdpe","vocff"], "s": "hvv" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["emqlklvrw","das","bzuq"], "s": "edm" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["hawikjbs","qi","ssvgttkzd"], "s": "rornirdphvargyce" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["hd","f","meivn"], "s": "hpm" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["mqhptbyzzv","mfubjraiqz"], "s": "mm" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["mvftnzftb","ga"], "s": "mg" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["ncgutvi","rsh"], "s": "nr" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["ntf","txayzc"], "s": "nt" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["nubibbe","wzwdrjcck"], "s": "nw" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["hphfek","kezkkq","oh"], "s": "hmo" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["odtclcvcj","ufhrhk"], "s": "ou" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["ojcn","naujlz"], "s": "on" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["iho","ignyipken","q"], "s": "wiq" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["olynt","xf"], "s": "ox" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["ir","wzhmxee","kjfwful"], "s": "iwn" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["ixo","wigba","raaphui"], "s": "dwr" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["opup","eme"], "s": "oe" }
assert my_solution.isAcronym(**test_input) == True

test_input = { "words": ["kmmoq","aoh","hznkpurdh"], "s": "kar" }
assert my_solution.isAcronym(**test_input) == False

test_input = { "words": ["ottxwi","akpixfvbel"], "s": "oa" }
assert my_solution.isAcronym(**test_input) == True


determine-the-minimum-sum-of-a-k-avoiding-array

Determine the Minimum Sum of a k-avoiding Array

Prompt:
"""
给你两个整数 n 和 k 。

对于一个由 不同 正整数组成的数组，如果其中不存在任何求和等于 k 的不同元素对，则称其为 k-avoiding 数组。

返回长度为 n 的 k-avoiding 数组的可能的最小总和。

示例 1：

输入：n = 5, k = 4
输出：18
解释：设若 k-avoiding 数组为 [1,2,4,5,6] ，其元素总和为 18 。
可以证明不存在总和小于 18 的 k-avoiding 数组。

示例 2：

输入：n = 2, k = 6
输出：3
解释：可以构造数组 [1,2] ，其元素总和为 3 。
可以证明不存在总和小于 3 的 k-avoiding 数组。

提示：

 * 1 <= n, k <= 50
"""
class Solution:
    def minimumSum(self, n: int, k: int) -> int:

给你两个整数 n 和 k 。

对于一个由 不同 正整数组成的数组，如果其中不存在任何求和等于 k 的不同元素对，则称其为 k-avoiding 数组。

返回长度为 n 的 k-avoiding 数组的可能的最小总和。

示例 1：

输入：n = 5, k = 4
输出：18
解释：设若 k-avoiding 数组为 [1,2,4,5,6] ，其元素总和为 18 。
可以证明不存在总和小于 18 的 k-avoiding 数组。

示例 2：

输入：n = 2, k = 6
输出：3
解释：可以构造数组 [1,2] ，其元素总和为 3 。
可以证明不存在总和小于 3 的 k-avoiding 数组。

提示：

 * 1 <= n, k <= 50

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

```

my_solution = Solution()

test_input = { "n": 5, "k": 4 }
assert my_solution.minimumSum(**test_input) == 18

test_input = { "n": 2, "k": 6 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 1, "k": 1 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 2 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 3 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 4 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 5 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 6 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 7 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 8 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 9 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 10 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 11 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 12 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 13 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 14 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 15 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 16 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 17 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 18 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 19 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 20 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 21 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 22 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 23 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 24 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 25 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 26 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 27 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 28 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 29 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 30 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 31 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 32 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 33 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 34 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 35 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 36 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 37 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 38 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 39 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 40 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 41 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 42 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 43 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 44 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 45 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 46 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 47 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 48 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 49 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 1, "k": 50 }
assert my_solution.minimumSum(**test_input) == 1

test_input = { "n": 2, "k": 1 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 2 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 3 }
assert my_solution.minimumSum(**test_input) == 4

test_input = { "n": 2, "k": 4 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 5 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 7 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 8 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 9 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 10 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 11 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 12 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 13 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 14 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 15 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 16 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 17 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 18 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 19 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 20 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 21 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 22 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 23 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 24 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 25 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 26 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 27 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 28 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 29 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 30 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 31 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 32 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 33 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 34 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 35 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 36 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 37 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 38 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 39 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 40 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 41 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 42 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 43 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 44 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 45 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 46 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 47 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 48 }
assert my_solution.minimumSum(**test_input) == 3

test_input = { "n": 2, "k": 49 }
assert my_solution.minimumSum(**test_input) == 3


maximize-the-profit-as-the-salesman

Maximize the Profit as the Salesman

Prompt:
"""
给你一个整数 n 表示数轴上的房屋数量，编号从 0 到 n - 1 。

另给你一个二维整数数组 offers ，其中 offers[i] = [starti, endi, goldi] 表示第 i 个买家想要以 goldi 枚金币的价格购买从 starti 到 endi 的所有房屋。

作为一名销售，你需要有策略地选择并销售房屋使自己的收入最大化。

返回你可以赚取的金币的最大数目。

注意 同一所房屋不能卖给不同的买家，并且允许保留一些房屋不进行出售。

示例 1：

输入：n = 5, offers = [[0,0,1],[0,2,2],[1,3,2]]
输出：3
解释：
有 5 所房屋，编号从 0 到 4 ，共有 3 个购买要约。
将位于 [0,0] 范围内的房屋以 1 金币的价格出售给第 1 位买家，并将位于 [1,3] 范围内的房屋以 2 金币的价格出售给第 3 位买家。
可以证明我们最多只能获得 3 枚金币。

示例 2：

输入：n = 5, offers = [[0,0,1],[0,2,10],[1,3,2]]
输出：10
解释：有 5 所房屋，编号从 0 到 4 ，共有 3 个购买要约。
将位于 [0,2] 范围内的房屋以 10 金币的价格出售给第 2 位买家。
可以证明我们最多只能获得 10 枚金币。

提示：

 * 1 <= n <= 105
 * 1 <= offers.length <= 105
 * offers[i].length == 3
 * 0 <= starti <= endi <= n - 1
 * 1 <= goldi <= 103
"""
class Solution:
    def maximizeTheProfit(self, n: int, offers: List[List[int]]) -> int:

给你一个整数 n 表示数轴上的房屋数量，编号从 0 到 n - 1 。

另给你一个二维整数数组 offers ，其中 offers[i] = [starti, endi, goldi] 表示第 i 个买家想要以 goldi 枚金币的价格购买从 starti 到 endi 的所有房屋。

作为一名销售，你需要有策略地选择并销售房屋使自己的收入最大化。

返回你可以赚取的金币的最大数目。

注意 同一所房屋不能卖给不同的买家，并且允许保留一些房屋不进行出售。

示例 1：

输入：n = 5, offers = [[0,0,1],[0,2,2],[1,3,2]]
输出：3
解释：
有 5 所房屋，编号从 0 到 4 ，共有 3 个购买要约。
将位于 [0,0] 范围内的房屋以 1 金币的价格出售给第 1 位买家，并将位于 [1,3] 范围内的房屋以 2 金币的价格出售给第 3 位买家。
可以证明我们最多只能获得 3 枚金币。

示例 2：

输入：n = 5, offers = [[0,0,1],[0,2,10],[1,3,2]]
输出：10
解释：有 5 所房屋，编号从 0 到 4 ，共有 3 个购买要约。
将位于 [0,2] 范围内的房屋以 10 金币的价格出售给第 2 位买家。
可以证明我们最多只能获得 10 枚金币。

提示：

 * 1 <= n <= 105
 * 1 <= offers.length <= 105
 * offers[i].length == 3
 * 0 <= starti <= endi <= n - 1
 * 1 <= goldi <= 103

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

```


find-the-longest-equal-subarray

Find the Longest Equal Subarray

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

如果子数组中所有元素都相等，则认为子数组是一个 等值子数组 。注意，空数组是 等值子数组 。

从 nums 中删除最多 k 个元素后，返回可能的最长等值子数组的长度。

子数组 是数组中一个连续且可能为空的元素序列。

示例 1：

输入：nums = [1,3,2,3,1,3], k = 3
输出：3
解释：最优的方案是删除下标 2 和下标 4 的元素。
删除后，nums 等于 [1, 3, 3, 3] 。
最长等值子数组从 i = 1 开始到 j = 3 结束，长度等于 3 。
可以证明无法创建更长的等值子数组。

示例 2：

输入：nums = [1,1,2,2,1,1], k = 2
输出：4
解释：最优的方案是删除下标 2 和下标 3 的元素。
删除后，nums 等于 [1, 1, 1, 1] 。
数组自身就是等值子数组，长度等于 4 。
可以证明无法创建更长的等值子数组。

提示：

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

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

如果子数组中所有元素都相等，则认为子数组是一个 等值子数组 。注意，空数组是 等值子数组 。

从 nums 中删除最多 k 个元素后，返回可能的最长等值子数组的长度。

子数组 是数组中一个连续且可能为空的元素序列。

示例 1：

输入：nums = [1,3,2,3,1,3], k = 3
输出：3
解释：最优的方案是删除下标 2 和下标 4 的元素。
删除后，nums 等于 [1, 3, 3, 3] 。
最长等值子数组从 i = 1 开始到 j = 3 结束，长度等于 3 。
可以证明无法创建更长的等值子数组。

示例 2：

输入：nums = [1,1,2,2,1,1], k = 2
输出：4
解释：最优的方案是删除下标 2 和下标 3 的元素。
删除后，nums 等于 [1, 1, 1, 1] 。
数组自身就是等值子数组，长度等于 4 。
可以证明无法创建更长的等值子数组。

提示：

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

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

```

my_solution = Solution()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


count-pairs-whose-sum-is-less-than-target

Count Pairs Whose Sum is Less than Target

Prompt:
"""
给你一个下标从 0 开始长度为 n 的整数数组 nums 和一个整数 target ，请你返回满足 0 <= i < j < n 且 nums[i] + nums[j] < target 的下标对 (i, j) 的数目。

示例 1：

输入：nums = [-1,1,2,3,1], target = 2
输出：3
解释：总共有 3 个下标对满足题目描述：
- (0, 1) ，0 < 1 且 nums[0] + nums[1] = 0 < target
- (0, 2) ，0 < 2 且 nums[0] + nums[2] = 1 < target
- (0, 4) ，0 < 4 且 nums[0] + nums[4] = 0 < target
注意 (0, 3) 不计入答案因为 nums[0] + nums[3] 不是严格小于 target 。

示例 2：

输入：nums = [-6,2,5,-2,-7,-1,3], target = -2
输出：10
解释：总共有 10 个下标对满足题目描述：
- (0, 1) ，0 < 1 且 nums[0] + nums[1] = -4 < target
- (0, 3) ，0 < 3 且 nums[0] + nums[3] = -8 < target
- (0, 4) ，0 < 4 且 nums[0] + nums[4] = -13 < target
- (0, 5) ，0 < 5 且 nums[0] + nums[5] = -7 < target
- (0, 6) ，0 < 6 且 nums[0] + nums[6] = -3 < target
- (1, 4) ，1 < 4 且 nums[1] + nums[4] = -5 < target
- (3, 4) ，3 < 4 且 nums[3] + nums[4] = -9 < target
- (3, 5) ，3 < 5 且 nums[3] + nums[5] = -3 < target
- (4, 5) ，4 < 5 且 nums[4] + nums[5] = -8 < target
- (4, 6) ，4 < 6 且 nums[4] + nums[6] = -4 < target

提示：

 * 1 <= nums.length == n <= 50
 * -50 <= nums[i], target <= 50
"""
class Solution:
    def countPairs(self, nums: List[int], target: int) -> int:

给你一个下标从 0 开始长度为 n 的整数数组 nums 和一个整数 target ，请你返回满足 0 <= i < j < n 且 nums[i] + nums[j] < target 的下标对 (i, j) 的数目。

示例 1：

输入：nums = [-1,1,2,3,1], target = 2
输出：3
解释：总共有 3 个下标对满足题目描述：
- (0, 1) ，0 < 1 且 nums[0] + nums[1] = 0 < target
- (0, 2) ，0 < 2 且 nums[0] + nums[2] = 1 < target
- (0, 4) ，0 < 4 且 nums[0] + nums[4] = 0 < target
注意 (0, 3) 不计入答案因为 nums[0] + nums[3] 不是严格小于 target 。

示例 2：

输入：nums = [-6,2,5,-2,-7,-1,3], target = -2
输出：10
解释：总共有 10 个下标对满足题目描述：
- (0, 1) ，0 < 1 且 nums[0] + nums[1] = -4 < target
- (0, 3) ，0 < 3 且 nums[0] + nums[3] = -8 < target
- (0, 4) ，0 < 4 且 nums[0] + nums[4] = -13 < target
- (0, 5) ，0 < 5 且 nums[0] + nums[5] = -7 < target
- (0, 6) ，0 < 6 且 nums[0] + nums[6] = -3 < target
- (1, 4) ，1 < 4 且 nums[1] + nums[4] = -5 < target
- (3, 4) ，3 < 4 且 nums[3] + nums[4] = -9 < target
- (3, 5) ，3 < 5 且 nums[3] + nums[5] = -3 < target
- (4, 5) ，4 < 5 且 nums[4] + nums[5] = -8 < target
- (4, 6) ，4 < 6 且 nums[4] + nums[6] = -4 < target

提示：

 * 1 <= nums.length == n <= 50
 * -50 <= nums[i], target <= 50

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

```

my_solution = Solution()

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

test_input = { "nums": [-6,2,5,-2,-7,-1,3], "target": -2 }
assert my_solution.countPairs(**test_input) == 10

test_input = { "nums": [9,-5,-5,5,-5,-4,-6,6,-6], "target": 3 }
assert my_solution.countPairs(**test_input) == 27

test_input = { "nums": [-8,-5,5,-4,10], "target": 2 }
assert my_solution.countPairs(**test_input) == 6

test_input = { "nums": [-5,0,-7,-1,9,8,-9,9], "target": -14 }
assert my_solution.countPairs(**test_input) == 1

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

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

test_input = { "nums": [-6,1,1,-1,-10,-7,1,-5,-4,0], "target": -15 }
assert my_solution.countPairs(**test_input) == 2

test_input = { "nums": [10,-2,-1,7,8,5,3,-4,-9], "target": -10 }
assert my_solution.countPairs(**test_input) == 2

test_input = { "nums": [3,8,-3,4,10,-6], "target": 1 }
assert my_solution.countPairs(**test_input) == 4

test_input = { "nums": [-4,-6,-7,8], "target": -13 }
assert my_solution.countPairs(**test_input) == 0

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

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

test_input = { "nums": [4,-8,-2,5,2,-9,6,5,-4], "target": -4 }
assert my_solution.countPairs(**test_input) == 9

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

test_input = { "nums": [-5,4,-6,-5,-10,-1,10,3], "target": 6 }
assert my_solution.countPairs(**test_input) == 24

test_input = { "nums": [-9,6,-4,10,1,8], "target": 11 }
assert my_solution.countPairs(**test_input) == 11

test_input = { "nums": [-10,-6,-8,-9,6,6,-6,-6,-3], "target": -2 }
assert my_solution.countPairs(**test_input) == 25

test_input = { "nums": [-7,7,6,-9,-4,10,8,-8,2,2], "target": -1 }
assert my_solution.countPairs(**test_input) == 17

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

test_input = { "nums": [8,-10,-9,6,-3,5,-2,-2,-7], "target": -4 }
assert my_solution.countPairs(**test_input) == 15

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

test_input = { "nums": [7,2,9,-10,-4,4,-3,0], "target": -20 }
assert my_solution.countPairs(**test_input) == 0

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

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

test_input = { "nums": [1,3,-10,5,-8,0,-5,-9], "target": -7 }
assert my_solution.countPairs(**test_input) == 11

test_input = { "nums": [-6,9,2,4,-9,2,4,-6,6,-9], "target": 11 }
assert my_solution.countPairs(**test_input) == 40

test_input = { "nums": [-10,-7,-5,-1,2,4,-6,6], "target": -3 }
assert my_solution.countPairs(**test_input) == 15

test_input = { "nums": [-1,0,1,9,-2,-8,-8,7], "target": 1 }
assert my_solution.countPairs(**test_input) == 16

test_input = { "nums": [1,9,3,2,9,-5,6,0,-6,6], "target": 9 }
assert my_solution.countPairs(**test_input) == 29

test_input = { "nums": [-3,-3,-4,1,4,9], "target": 6 }
assert my_solution.countPairs(**test_input) == 11

test_input = { "nums": [-10,3,-5,2,-10,7,9], "target": 4 }
assert my_solution.countPairs(**test_input) == 14

test_input = { "nums": [7,10,9,8,-9,1,-7,10,-4,2], "target": 4 }
assert my_solution.countPairs(**test_input) == 21

test_input = { "nums": [9,-9,0,5,4], "target": 14 }
assert my_solution.countPairs(**test_input) == 9

test_input = { "nums": [7,9,7,-10,-6,-8,-5], "target": 2 }
assert my_solution.countPairs(**test_input) == 14

test_input = { "nums": [8,-5,0,4], "target": 0 }
assert my_solution.countPairs(**test_input) == 2

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

test_input = { "nums": [-7,-4,3,9,10,5,-1,1,-7], "target": -4 }
assert my_solution.countPairs(**test_input) == 8

test_input = { "nums": [0,8,9,-9,8,-2,-1,2,5], "target": -1 }
assert my_solution.countPairs(**test_input) == 7

test_input = { "nums": [10,4,-9,8,-10,3], "target": -7 }
assert my_solution.countPairs(**test_input) == 1

test_input = { "nums": [-6,-6,6,-4,-5,-1,10,-8,1], "target": -13 }
assert my_solution.countPairs(**test_input) == 2

test_input = { "nums": [7,3,-4,1,-9,-8,10,4,-1], "target": -2 }
assert my_solution.countPairs(**test_input) == 13

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

test_input = { "nums": [10,-8,-9,-7,2,-10,4,7,6,6], "target": 14 }
assert my_solution.countPairs(**test_input) == 41

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

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

test_input = { "nums": [-8,-9,-10,0,-5,-5], "target": -15 }
assert my_solution.countPairs(**test_input) == 3

test_input = { "nums": [-8,9,-10,2,-10,-6,-1,-8], "target": -4 }
assert my_solution.countPairs(**test_input) == 19

test_input = { "nums": [4,-7,8,7,-4,3,7,7,-2,-10], "target": 4 }
assert my_solution.countPairs(**test_input) == 25

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

test_input = { "nums": [2,-4,5,3,7,10,9,-1,9,0], "target": 9 }
assert my_solution.countPairs(**test_input) == 23

test_input = { "nums": [-2,-5,9,-3,-8,5,-1,3,-9], "target": 1 }
assert my_solution.countPairs(**test_input) == 23

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

test_input = { "nums": [10,4,-3,9,-8,6], "target": 14 }
assert my_solution.countPairs(**test_input) == 11

test_input = { "nums": [-10,-6,6,-7,1,-7,9,3,1], "target": 15 }
assert my_solution.countPairs(**test_input) == 35

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

test_input = { "nums": [-10,-8,8,-2], "target": 0 }
assert my_solution.countPairs(**test_input) == 4

test_input = { "nums": [-2,2,-7,-5,1,6,8], "target": 0 }
assert my_solution.countPairs(**test_input) == 9

test_input = { "nums": [4,-4,-5,-8,9], "target": -10 }
assert my_solution.countPairs(**test_input) == 2

test_input = { "nums": [-5,-4,-6,-7,9,-10,0,4,9,-1], "target": -7 }
assert my_solution.countPairs(**test_input) == 13

test_input = { "nums": [-10,-6,6,-3,10,-6,4,-8], "target": -9 }
assert my_solution.countPairs(**test_input) == 8

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

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

test_input = { "nums": [9,4,-8,8,9,-4], "target": -16 }
assert my_solution.countPairs(**test_input) == 0

test_input = { "nums": [9,-4,8,-9,-2,-2], "target": -11 }
assert my_solution.countPairs(**test_input) == 1

test_input = { "nums": [-7,1,3,7,6,3], "target": 10 }
assert my_solution.countPairs(**test_input) == 12

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

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

test_input = { "nums": [5,0,2,4,2,-7], "target": 2 }
assert my_solution.countPairs(**test_input) == 5

test_input = { "nums": [4,-5,-4,-2,-9,-6,-10,-10,2,-8], "target": -19 }
assert my_solution.countPairs(**test_input) == 1

test_input = { "nums": [-10,10,-9,-2,3,-2,-7,-1,-6,7], "target": -17 }
assert my_solution.countPairs(**test_input) == 1

test_input = { "nums": [-9,-9,3,7,-9,-10,2,3,-4], "target": -13 }
assert my_solution.countPairs(**test_input) == 7

test_input = { "nums": [-5,-4,-10,7], "target": 14 }
assert my_solution.countPairs(**test_input) == 6

test_input = { "nums": [-3,4,-6,-6,1,-10,-1,-8], "target": -11 }
assert my_solution.countPairs(**test_input) == 7

test_input = { "nums": [-7,1,-5,8,-7,-3,2,-2,-2,7], "target": -5 }
assert my_solution.countPairs(**test_input) == 14

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

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

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

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

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

test_input = { "nums": [3,-3,-7,-6,-5,-2], "target": -2 }
assert my_solution.countPairs(**test_input) == 12

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

test_input = { "nums": [-8,9,2,5,9,-4,3], "target": 6 }
assert my_solution.countPairs(**test_input) == 12

test_input = { "nums": [0,-6,-5,-8,-4,0,7], "target": 7 }
assert my_solution.countPairs(**test_input) == 19

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

test_input = { "nums": [-7,9,-3,-5,-9,-3,-8,-2,1,2], "target": -8 }
assert my_solution.countPairs(**test_input) == 15

test_input = { "nums": [4,10,-7,0,-3,5,9,6,8,-4], "target": 13 }
assert my_solution.countPairs(**test_input) == 34

test_input = { "nums": [2,-6,0,5,-9,-8,6,5], "target": -3 }
assert my_solution.countPairs(**test_input) == 11

test_input = { "nums": [-4,6,-2,10,-5,-7,-8,-1], "target": -5 }
assert my_solution.countPairs(**test_input) == 13

test_input = { "nums": [10,4,8,-1,9,-5,-1,-7,-9], "target": 19 }
assert my_solution.countPairs(**test_input) == 35

test_input = { "nums": [-6,5,3,-2,0,3,-7,-7], "target": -8 }
assert my_solution.countPairs(**test_input) == 5

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

test_input = { "nums": [-7,8,3,-1,2,1,-10], "target": -7 }
assert my_solution.countPairs(**test_input) == 5

test_input = { "nums": [7,-3,-5,9,-10,-1,-3,-3,-3,1], "target": 6 }
assert my_solution.countPairs(**test_input) == 36

test_input = { "nums": [-5,-10,-7,-3,-2,-2], "target": -15 }
assert my_solution.countPairs(**test_input) == 1

test_input = { "nums": [-4,6,-9,-8,-9,-9], "target": -17 }
assert my_solution.countPairs(**test_input) == 3

test_input = { "nums": [-3,-8,-6,-4,-8,-10,-2,5,-2], "target": 1 }
assert my_solution.countPairs(**test_input) == 32

test_input = { "nums": [1,1,-6,8,2,10,-7,-9,-9], "target": -7 }
assert my_solution.countPairs(**test_input) == 10

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

test_input = { "nums": [-5,10,-5,1,7,-8,8,-6,-6], "target": 2 }
assert my_solution.countPairs(**test_input) == 19


make-string-a-subsequence-using-cyclic-increments

Make String a Subsequence Using Cyclic Increments

Prompt:
"""
给你一个下标从 0 开始的字符串 str1 和 str2 。

一次操作中，你选择 str1 中的若干下标。对于选中的每一个下标 i ，你将 str1[i] 循环 递增，变成下一个字符。也就是说 'a' 变成 'b' ，'b' 变成 'c' ，以此类推，'z' 变成 'a' 。

如果执行以上操作 至多一次 ，可以让 str2 成为 str1 的子序列，请你返回 true ，否则返回 false 。

注意：一个字符串的子序列指的是从原字符串中删除一些（可以一个字符也不删）字符后，剩下字符按照原本先后顺序组成的新字符串。

示例 1：

输入：str1 = "abc", str2 = "ad"
输出：true
解释：选择 str1 中的下标 2 。
将 str1[2] 循环递增，得到 'd' 。
因此，str1 变成 "abd" 且 str2 现在是一个子序列。所以返回 true 。

示例 2：

输入：str1 = "zc", str2 = "ad"
输出：true
解释：选择 str1 中的下标 0 和 1 。
将 str1[0] 循环递增得到 'a' 。
将 str1[1] 循环递增得到 'd' 。
因此，str1 变成 "ad" 且 str2 现在是一个子序列。所以返回 true 。

示例 3：

输入：str1 = "ab", str2 = "d"
输出：false
解释：这个例子中，没法在执行一次操作的前提下，将 str2 变为 str1 的子序列。
所以返回 false 。

提示：

 * 1 <= str1.length <= 105
 * 1 <= str2.length <= 105
 * str1 和 str2 只包含小写英文字母。
"""
class Solution:
    def canMakeSubsequence(self, str1: str, str2: str) -> bool:

给你一个下标从 0 开始的字符串 str1 和 str2 。

一次操作中，你选择 str1 中的若干下标。对于选中的每一个下标 i ，你将 str1[i] 循环 递增，变成下一个字符。也就是说 'a' 变成 'b' ，'b' 变成 'c' ，以此类推，'z' 变成 'a' 。

如果执行以上操作 至多一次 ，可以让 str2 成为 str1 的子序列，请你返回 true ，否则返回 false 。

注意：一个字符串的子序列指的是从原字符串中删除一些（可以一个字符也不删）字符后，剩下字符按照原本先后顺序组成的新字符串。

示例 1：

输入：str1 = "abc", str2 = "ad"
输出：true
解释：选择 str1 中的下标 2 。
将 str1[2] 循环递增，得到 'd' 。
因此，str1 变成 "abd" 且 str2 现在是一个子序列。所以返回 true 。

示例 2：

输入：str1 = "zc", str2 = "ad"
输出：true
解释：选择 str1 中的下标 0 和 1 。
将 str1[0] 循环递增得到 'a' 。
将 str1[1] 循环递增得到 'd' 。
因此，str1 变成 "ad" 且 str2 现在是一个子序列。所以返回 true 。

示例 3：

输入：str1 = "ab", str2 = "d"
输出：false
解释：这个例子中，没法在执行一次操作的前提下，将 str2 变为 str1 的子序列。
所以返回 false 。

提示：

 * 1 <= str1.length <= 105
 * 1 <= str2.length <= 105
 * str1 和 str2 只包含小写英文字母。

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

```

my_solution = Solution()

test_input = { "str1": "ab", "str2": "d" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "a", "str2": "d" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "abc", "str2": "ad" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "b", "str2": "v" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "c", "str2": "b" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "c", "str2": "k" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "zc", "str2": "ad" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "b", "str2": "c" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "c", "str2": "m" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "d", "str2": "h" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "f", "str2": "f" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "f", "str2": "g" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "d", "str2": "m" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "g", "str2": "g" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "h", "str2": "i" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "d", "str2": "x" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "i", "str2": "j" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "j", "str2": "j" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "j", "str2": "k" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "f", "str2": "s" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "i", "str2": "e" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "k", "str2": "k" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "l", "str2": "d" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "k", "str2": "l" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "m", "str2": "e" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "l", "str2": "l" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "m", "str2": "n" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "o", "str2": "p" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "o", "str2": "c" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "o", "str2": "n" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "p", "str2": "a" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "p", "str2": "s" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "q", "str2": "q" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "q", "str2": "j" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "s", "str2": "f" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "s", "str2": "u" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "r", "str2": "s" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "t", "str2": "h" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "t", "str2": "k" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "t", "str2": "u" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "u", "str2": "w" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "u", "str2": "u" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "w", "str2": "y" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "u", "str2": "v" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "at", "str2": "se" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "cl", "str2": "qs" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "v", "str2": "v" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "w", "str2": "w" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "cq", "str2": "xz" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "y", "str2": "y" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "ct", "str2": "xb" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "z", "str2": "a" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "fs", "str2": "rd" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "z", "str2": "z" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "gq", "str2": "kn" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "hq", "str2": "dk" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "dm", "str2": "e" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "eh", "str2": "e" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "ir", "str2": "ka" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "is", "str2": "af" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "ja", "str2": "zz" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "jq", "str2": "zi" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "ke", "str2": "qw" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "fp", "str2": "p" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "hz", "str2": "z" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "ia", "str2": "a" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "lo", "str2": "fa" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "km", "str2": "l" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "mu", "str2": "za" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "np", "str2": "q" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "nh", "str2": "pa" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "oj", "str2": "j" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "oh", "str2": "hu" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "pg", "str2": "xb" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "uq", "str2": "v" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "pl", "str2": "yi" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "ww", "str2": "x" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "xh", "str2": "x" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "yg", "str2": "y" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "px", "str2": "dh" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "rm", "str2": "au" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "se", "str2": "vs" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "yw", "str2": "w" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "st", "str2": "zf" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "dby", "str2": "z" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "sx", "str2": "fx" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "ei", "str2": "ei" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "ff", "str2": "fg" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "to", "str2": "yv" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "tv", "str2": "ei" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "va", "str2": "ow" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "jc", "str2": "jd" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "jrg", "str2": "h" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "lf", "str2": "lg" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "agb", "str2": "vgz" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "amk", "str2": "nto" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "atd", "str2": "xrr" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "pc", "str2": "qc" }
assert my_solution.canMakeSubsequence(**test_input) == True

test_input = { "str1": "ayt", "str2": "nov" }
assert my_solution.canMakeSubsequence(**test_input) == False

test_input = { "str1": "qv", "str2": "rv" }
assert my_solution.canMakeSubsequence(**test_input) == True


sorting-three-groups

Sorting Three Groups

Prompt:
"""
给你一个下标从 0 开始长度为 n 的整数数组 nums 。

从 0 到 n - 1 的数字被分为编号从 1 到 3 的三个组，数字 i 属于组 nums[i] 。注意，有的组可能是 空的 。

你可以执行以下操作任意次：

 * 选择数字 x 并改变它的组。更正式的，你可以将 nums[x] 改为数字 1 到 3 中的任意一个。

你将按照以下过程构建一个新的数组 res ：

 1. 将每个组中的数字分别排序。
 2. 将组 1 ，2 和 3 中的元素 依次 连接以得到 res 。

如果得到的 res 是 非递减顺序的，那么我们称数组 nums 是 美丽数组 。

请你返回将 nums 变为 美丽数组 需要的最少步数。

示例 1：

输入：nums = [2,1,3,2,1]
输出：3
解释：以下三步操作是最优方案：
1. 将 nums[0] 变为 1 。
2. 将 nums[2] 变为 1 。
3. 将 nums[3] 变为 1 。
执行以上操作后，将每组中的数字排序，组 1 为 [0,1,2,3,4] ，组 2 和组 3 都为空。所以 res 等于 [0,1,2,3,4] ，它是非递减顺序的。
三步操作是最少需要的步数。

示例 2：

输入：nums = [1,3,2,1,3,3]
输出：2
解释：以下两步操作是最优方案：
1. 将 nums[1] 变为 1 。
2. 将 nums[2] 变为 1 。
执行以上操作后，将每组中的数字排序，组 1 为 [0,1,2,3] ，组 2 为空，组 3 为 [4,5] 。所以 res 等于 [0,1,2,3,4,5] ，它是非递减顺序的。
两步操作是最少需要的步数。

示例 3：

输入：nums = [2,2,2,2,3,3]
输出：0
解释：不需要执行任何操作。
组 1 为空，组 2 为 [0,1,2,3] ，组 3 为 [4,5] 。所以 res 等于 [0,1,2,3,4,5] ，它是非递减顺序的。

提示：

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

给你一个下标从 0 开始长度为 n 的整数数组 nums 。

从 0 到 n - 1 的数字被分为编号从 1 到 3 的三个组，数字 i 属于组 nums[i] 。注意，有的组可能是 空的 。

你可以执行以下操作任意次：

 * 选择数字 x 并改变它的组。更正式的，你可以将 nums[x] 改为数字 1 到 3 中的任意一个。

你将按照以下过程构建一个新的数组 res ：

 1. 将每个组中的数字分别排序。
 2. 将组 1 ，2 和 3 中的元素 依次 连接以得到 res 。

如果得到的 res 是 非递减顺序的，那么我们称数组 nums 是 美丽数组 。

请你返回将 nums 变为 美丽数组 需要的最少步数。

示例 1：

输入：nums = [2,1,3,2,1]
输出：3
解释：以下三步操作是最优方案：
1. 将 nums[0] 变为 1 。
2. 将 nums[2] 变为 1 。
3. 将 nums[3] 变为 1 。
执行以上操作后，将每组中的数字排序，组 1 为 [0,1,2,3,4] ，组 2 和组 3 都为空。所以 res 等于 [0,1,2,3,4] ，它是非递减顺序的。
三步操作是最少需要的步数。

示例 2：

输入：nums = [1,3,2,1,3,3]
输出：2
解释：以下两步操作是最优方案：
1. 将 nums[1] 变为 1 。
2. 将 nums[2] 变为 1 。
执行以上操作后，将每组中的数字排序，组 1 为 [0,1,2,3] ，组 2 为空，组 3 为 [4,5] 。所以 res 等于 [0,1,2,3,4,5] ，它是非递减顺序的。
两步操作是最少需要的步数。

示例 3：

输入：nums = [2,2,2,2,3,3]
输出：0
解释：不需要执行任何操作。
组 1 为空，组 2 为 [0,1,2,3] ，组 3 为 [4,5] 。所以 res 等于 [0,1,2,3,4,5] ，它是非递减顺序的。

提示：

 * 1 <= nums.length <= 100
 * 1 <= nums[i] <= 3

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

```

my_solution = Solution()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


number-of-beautiful-integers-in-the-range

Number of Beautiful Integers in the Range

Prompt:
"""
给你正整数 low ，high 和 k 。

如果一个数满足以下两个条件，那么它是 美丽的 ：

 * 偶数数位的数目与奇数数位的数目相同。
 * 这个整数可以被 k 整除。

请你返回范围 [low, high] 中美丽整数的数目。

示例 1：

输入：low = 10, high = 20, k = 3
输出：2
解释：给定范围中有 2 个美丽数字：[12,18]
- 12 是美丽整数，因为它有 1 个奇数数位和 1 个偶数数位，而且可以被 k = 3 整除。
- 18 是美丽整数，因为它有 1 个奇数数位和 1 个偶数数位，而且可以被 k = 3 整除。
以下是一些不是美丽整数的例子：
- 16 不是美丽整数，因为它不能被 k = 3 整除。
- 15 不是美丽整数，因为它的奇数数位和偶数数位的数目不相等。
给定范围内总共有 2 个美丽整数。

示例 2：

输入：low = 1, high = 10, k = 1
输出：1
解释：给定范围中有 1 个美丽数字：[10]
- 10 是美丽整数，因为它有 1 个奇数数位和 1 个偶数数位，而且可以被 k = 1 整除。
给定范围内总共有 1 个美丽整数。

示例 3：

输入：low = 5, high = 5, k = 2
输出：0
解释：给定范围中有 0 个美丽数字。
- 5 不是美丽整数，因为它的奇数数位和偶数数位的数目不相等。

提示：

 * 0 < low <= high <= 109
 * 0 < k <= 20
"""
class Solution:
    def numberOfBeautifulIntegers(self, low: int, high: int, k: int) -> int:

给你正整数 low ，high 和 k 。

如果一个数满足以下两个条件，那么它是 美丽的 ：

 * 偶数数位的数目与奇数数位的数目相同。
 * 这个整数可以被 k 整除。

请你返回范围 [low, high] 中美丽整数的数目。

示例 1：

输入：low = 10, high = 20, k = 3
输出：2
解释：给定范围中有 2 个美丽数字：[12,18]
- 12 是美丽整数，因为它有 1 个奇数数位和 1 个偶数数位，而且可以被 k = 3 整除。
- 18 是美丽整数，因为它有 1 个奇数数位和 1 个偶数数位，而且可以被 k = 3 整除。
以下是一些不是美丽整数的例子：
- 16 不是美丽整数，因为它不能被 k = 3 整除。
- 15 不是美丽整数，因为它的奇数数位和偶数数位的数目不相等。
给定范围内总共有 2 个美丽整数。

示例 2：

输入：low = 1, high = 10, k = 1
输出：1
解释：给定范围中有 1 个美丽数字：[10]
- 10 是美丽整数，因为它有 1 个奇数数位和 1 个偶数数位，而且可以被 k = 1 整除。
给定范围内总共有 1 个美丽整数。

示例 3：

输入：low = 5, high = 5, k = 2
输出：0
解释：给定范围中有 0 个美丽数字。
- 5 不是美丽整数，因为它的奇数数位和偶数数位的数目不相等。

提示：

 * 0 < low <= high <= 109
 * 0 < k <= 20

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

```

my_solution = Solution()

test_input = { "low": 10, "high": 20, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 1, "high": 10, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 5, "high": 5, "k": 2 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 3, "high": 31, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 25, "high": 31, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 9, "high": 25, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 58, "high": 72, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 5, "high": 79, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 26, "high": 74, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 4

test_input = { "low": 36, "high": 65, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 12, "high": 84, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 4

test_input = { "low": 13, "high": 91, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 8, "high": 18, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 22, "high": 59, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 15, "high": 27, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 4, "high": 9, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 14, "high": 81, "k": 17 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 12, "high": 33, "k": 18 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 10, "high": 17, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 42, "high": 58, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 22, "high": 42, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 5, "high": 8, "k": 5 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 12, "high": 75, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 2, "high": 28, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 9

test_input = { "low": 29, "high": 35, "k": 17 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 13, "high": 21, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 1, "high": 13, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 12, "high": 21, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 47, "high": 72, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 1, "high": 35, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 38, "high": 52, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 10, "high": 74, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 11

test_input = { "low": 60, "high": 92, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 3, "high": 25, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 63, "high": 65, "k": 20 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 22, "high": 77, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 4

test_input = { "low": 1, "high": 1, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 28, "high": 73, "k": 20 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 21, "high": 32, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 43, "high": 43, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 31, "high": 68, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 1, "high": 8, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 47, "high": 100, "k": 18 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 45, "high": 84, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 31, "high": 80, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 14, "high": 14, "k": 5 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 21, "high": 88, "k": 10 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 11, "high": 42, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 6

test_input = { "low": 19, "high": 53, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 57, "high": 98, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 4

test_input = { "low": 57, "high": 69, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 17, "high": 64, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 23

test_input = { "low": 29, "high": 40, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 36, "high": 60, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 16, "high": 23, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 36, "high": 99, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 11

test_input = { "low": 23, "high": 83, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 6

test_input = { "low": 4, "high": 5, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 15, "high": 21, "k": 2 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 51, "high": 76, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 24, "high": 34, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 24, "high": 99, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 38

test_input = { "low": 37, "high": 63, "k": 10 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 19, "high": 23, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 35, "high": 70, "k": 17 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 3, "high": 18, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 30, "high": 64, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 3, "high": 12, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 14, "high": 21, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 19, "high": 21, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 54, "high": 78, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 24, "high": 36, "k": 20 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 54, "high": 58, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 74, "high": 88, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 45, "high": 58, "k": 14 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 51, "high": 99, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 8, "high": 26, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 12, "high": 92, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 15

test_input = { "low": 18, "high": 91, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 14, "high": 53, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 4, "high": 10, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 7, "high": 24, "k": 5 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 1, "high": 25, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 7, "high": 20, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 51, "high": 92, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 21

test_input = { "low": 73, "high": 73, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 50, "high": 63, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 30, "high": 51, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 2, "high": 65, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 5

test_input = { "low": 49, "high": 87, "k": 20 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 3, "high": 6, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 16, "high": 17, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 17, "high": 32, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 13, "high": 14, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 25, "high": 42, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 18, "high": 46, "k": 5 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 1, "high": 65, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 5

test_input = { "low": 6, "high": 43, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 5, "high": 9, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 1, "high": 75, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 7