minimum-changes-to-make-k-semi-palindromes

Minimum Changes to Make K Semi-palindromes

Prompt:
"""
给你一个字符串 s 和一个整数 k ，请你将 s 分成 k 个 子字符串 ，使得每个 子字符串 变成 半回文串 需要修改的字符数目最少。

请你返回一个整数，表示需要修改的 最少 字符数目。

注意：

 * 如果一个字符串从左往右和从右往左读是一样的，那么它是一个 回文串 。
 * 如果长度为 len 的字符串存在一个满足 1 <= d < len 的正整数 d ，len % d == 0 成立且所有对 d 做除法余数相同的下标对应的字符连起来得到的字符串都是 回文串 ，那么我们说这个字符串是 半回文串 。比方说 "aa" ，"aba" ，"adbgad" 和 "abab" 都是 半回文串 ，而 "a" ，"ab" 和 "abca" 不是。
 * 子字符串 指的是一个字符串中一段连续的字符序列。

示例 1：

输入：s = "abcac", k = 2
输出：1
解释：我们可以将 s 分成子字符串 "ab" 和 "cac" 。子字符串 "cac" 已经是半回文串。如果我们将 "ab" 变成 "aa" ，它也会变成一个 d = 1 的半回文串。
该方案是将 s 分成 2 个子字符串的前提下，得到 2 个半回文子字符串需要的最少修改次数。所以答案为 1 。

示例 2:

输入：s = "abcdef", k = 2
输出：2
解释：我们可以将 s 分成子字符串 "abc" 和 "def" 。子字符串 "abc" 和 "def" 都需要修改一个字符得到半回文串，所以我们总共需要 2 次字符修改使所有子字符串变成半回文串。
该方案是将 s 分成 2 个子字符串的前提下，得到 2 个半回文子字符串需要的最少修改次数。所以答案为 2 。

示例 3：

输入：s = "aabbaa", k = 3
输出：0
解释：我们可以将 s 分成子字符串 "aa" ，"bb" 和 "aa" 。
字符串 "aa" 和 "bb" 都已经是半回文串了。所以答案为 0 。

提示：

 * 2 <= s.length <= 200
 * 1 <= k <= s.length / 2
 * s 只包含小写英文字母。
"""
class Solution:
    def minimumChanges(self, s: str, k: int) -> int:

给你一个字符串 s 和一个整数 k ，请你将 s 分成 k 个 子字符串 ，使得每个 子字符串 变成 半回文串 需要修改的字符数目最少。

请你返回一个整数，表示需要修改的 最少 字符数目。

注意：

 * 如果一个字符串从左往右和从右往左读是一样的，那么它是一个 回文串 。
 * 如果长度为 len 的字符串存在一个满足 1 <= d < len 的正整数 d ，len % d == 0 成立且所有对 d 做除法余数相同的下标对应的字符连起来得到的字符串都是 回文串 ，那么我们说这个字符串是 半回文串 。比方说 "aa" ，"aba" ，"adbgad" 和 "abab" 都是 半回文串 ，而 "a" ，"ab" 和 "abca" 不是。
 * 子字符串 指的是一个字符串中一段连续的字符序列。

示例 1：

输入：s = "abcac", k = 2
输出：1
解释：我们可以将 s 分成子字符串 "ab" 和 "cac" 。子字符串 "cac" 已经是半回文串。如果我们将 "ab" 变成 "aa" ，它也会变成一个 d = 1 的半回文串。
该方案是将 s 分成 2 个子字符串的前提下，得到 2 个半回文子字符串需要的最少修改次数。所以答案为 1 。

示例 2:

输入：s = "abcdef", k = 2
输出：2
解释：我们可以将 s 分成子字符串 "abc" 和 "def" 。子字符串 "abc" 和 "def" 都需要修改一个字符得到半回文串，所以我们总共需要 2 次字符修改使所有子字符串变成半回文串。
该方案是将 s 分成 2 个子字符串的前提下，得到 2 个半回文子字符串需要的最少修改次数。所以答案为 2 。

示例 3：

输入：s = "aabbaa", k = 3
输出：0
解释：我们可以将 s 分成子字符串 "aa" ，"bb" 和 "aa" 。
字符串 "aa" 和 "bb" 都已经是半回文串了。所以答案为 0 。

提示：

 * 2 <= s.length <= 200
 * 1 <= k <= s.length / 2
 * s 只包含小写英文字母。

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

```

my_solution = Solution()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


find-indices-with-index-and-value-difference-i

Find Indices With Index and Value Difference I

Prompt:
"""
给你一个下标从 0 开始、长度为 n 的整数数组 nums ，以及整数 indexDifference 和整数 valueDifference 。

你的任务是从范围 [0, n - 1] 内找出  2 个满足下述所有条件的下标 i 和 j ：

 * abs(i - j) >= indexDifference 且
 * abs(nums[i] - nums[j]) >= valueDifference

返回整数数组 answer。如果存在满足题目要求的两个下标，则 answer = [i, j] ；否则，answer = [-1, -1] 。如果存在多组可供选择的下标对，只需要返回其中任意一组即可。

注意：i 和 j 可能 相等 。

示例 1：

输入：nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
输出：[0,3]
解释：在示例中，可以选择 i = 0 和 j = 3 。
abs(0 - 3) >= 2 且 abs(nums[0] - nums[3]) >= 4 。
因此，[0,3] 是一个符合题目要求的答案。
[3,0] 也是符合题目要求的答案。

示例 2：

输入：nums = [2,1], indexDifference = 0, valueDifference = 0
输出：[0,0]
解释：
在示例中，可以选择 i = 0 和 j = 0 。
abs(0 - 0) >= 0 且 abs(nums[0] - nums[0]) >= 0 。
因此，[0,0] 是一个符合题目要求的答案。
[0,1]、[1,0] 和 [1,1] 也是符合题目要求的答案。

示例 3：

输入：nums = [1,2,3], indexDifference = 2, valueDifference = 4
输出：[-1,-1]
解释：在示例中，可以证明无法找出 2 个满足所有条件的下标。
因此，返回 [-1,-1] 。

提示：

 * 1 <= n == nums.length <= 100
 * 0 <= nums[i] <= 50
 * 0 <= indexDifference <= 100
 * 0 <= valueDifference <= 50
"""
class Solution:
    def findIndices(self, nums: List[int], indexDifference: int, valueDifference: int) -> List[int]:

给你一个下标从 0 开始、长度为 n 的整数数组 nums ，以及整数 indexDifference 和整数 valueDifference 。

你的任务是从范围 [0, n - 1] 内找出  2 个满足下述所有条件的下标 i 和 j ：

 * abs(i - j) >= indexDifference 且
 * abs(nums[i] - nums[j]) >= valueDifference

返回整数数组 answer。如果存在满足题目要求的两个下标，则 answer = [i, j] ；否则，answer = [-1, -1] 。如果存在多组可供选择的下标对，只需要返回其中任意一组即可。

注意：i 和 j 可能 相等 。

示例 1：

输入：nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
输出：[0,3]
解释：在示例中，可以选择 i = 0 和 j = 3 。
abs(0 - 3) >= 2 且 abs(nums[0] - nums[3]) >= 4 。
因此，[0,3] 是一个符合题目要求的答案。
[3,0] 也是符合题目要求的答案。

示例 2：

输入：nums = [2,1], indexDifference = 0, valueDifference = 0
输出：[0,0]
解释：
在示例中，可以选择 i = 0 和 j = 0 。
abs(0 - 0) >= 0 且 abs(nums[0] - nums[0]) >= 0 。
因此，[0,0] 是一个符合题目要求的答案。
[0,1]、[1,0] 和 [1,1] 也是符合题目要求的答案。

示例 3：

输入：nums = [1,2,3], indexDifference = 2, valueDifference = 4
输出：[-1,-1]
解释：在示例中，可以证明无法找出 2 个满足所有条件的下标。
因此，返回 [-1,-1] 。

提示：

 * 1 <= n == nums.length <= 100
 * 0 <= nums[i] <= 50
 * 0 <= indexDifference <= 100
 * 0 <= valueDifference <= 50

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

```

my_solution = Solution()

test_input = { "nums": [5,1,4,1], "indexDifference": 2, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,3]

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

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

test_input = { "nums": [0], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

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

test_input = { "nums": [3], "indexDifference": 1, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [4], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [5], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [7], "indexDifference": 1, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [8], "indexDifference": 0, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [8], "indexDifference": 1, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [10], "indexDifference": 0, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [11], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [18], "indexDifference": 1, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [38], "indexDifference": 1, "valueDifference": 34 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [40], "indexDifference": 1, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [5,10], "indexDifference": 1, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [5,48], "indexDifference": 0, "valueDifference": 29 }
assert my_solution.findIndices(**test_input) == [0,1]

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

test_input = { "nums": [7,6], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [8,8], "indexDifference": 1, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [17,31], "indexDifference": 1, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [21,22], "indexDifference": 1, "valueDifference": 21 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [48,40], "indexDifference": 2, "valueDifference": 31 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [2,8,0], "indexDifference": 2, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [2,29,0], "indexDifference": 0, "valueDifference": 12 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [3,0,7], "indexDifference": 2, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [4,22,43], "indexDifference": 0, "valueDifference": 34 }
assert my_solution.findIndices(**test_input) == [0,2]

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

test_input = { "nums": [5,9,2], "indexDifference": 0, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [6,2,7], "indexDifference": 2, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [-1,-1]

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

test_input = { "nums": [6,8,0], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,36,21], "indexDifference": 1, "valueDifference": 20 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [9,4,7], "indexDifference": 0, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [9,50,31], "indexDifference": 1, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [31,23,36], "indexDifference": 1, "valueDifference": 11 }
assert my_solution.findIndices(**test_input) == [1,2]

test_input = { "nums": [40,21,1], "indexDifference": 2, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [0,5,10,5], "indexDifference": 3, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [1,28,24,35], "indexDifference": 3, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [2,7,10,4], "indexDifference": 0, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,1]

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

test_input = { "nums": [7,5,6,2], "indexDifference": 2, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [9,3,6,4], "indexDifference": 1, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [34,46,11,45], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [36,37,40,9], "indexDifference": 2, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [37,25,48,13], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [45,6,29,21], "indexDifference": 3, "valueDifference": 36 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [1,5,7,9,2], "indexDifference": 3, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [7,2,1,8,3], "indexDifference": 0, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [2,3]

test_input = { "nums": [8,9,8,0,4], "indexDifference": 1, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [9,1,10,0,10], "indexDifference": 0, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,1]

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

test_input = { "nums": [10,1,10,12,1], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [17,46,31,28,28], "indexDifference": 0, "valueDifference": 46 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [17,49,1,47,12], "indexDifference": 2, "valueDifference": 17 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [32,49,3,40,44], "indexDifference": 1, "valueDifference": 37 }
assert my_solution.findIndices(**test_input) == [1,2]

test_input = { "nums": [46,43,16,16,34], "indexDifference": 3, "valueDifference": 13 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [49,36,18,4,33], "indexDifference": 3, "valueDifference": 20 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [0,7,10,6,6,5], "indexDifference": 1, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [2,0,3,4,0,5], "indexDifference": 3, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [1,5]

test_input = { "nums": [3,8,9,7,2,3], "indexDifference": 3, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [3,27,38,47,38,4], "indexDifference": 0, "valueDifference": 10 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [4,13,48,50,1,26], "indexDifference": 4, "valueDifference": 34 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [6,1,2,6,4,6], "indexDifference": 2, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,1,0,9,5,9], "indexDifference": 2, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,3,7,5,7,9], "indexDifference": 1, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [12,37,7,16,5,34], "indexDifference": 3, "valueDifference": 27 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [17,46,48,25,22,4], "indexDifference": 2, "valueDifference": 30 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [18,18,7,10,9,50], "indexDifference": 2, "valueDifference": 32 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [18,42,37,13,49,42], "indexDifference": 3, "valueDifference": 46 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [23,31,14,42,0,49], "indexDifference": 4, "valueDifference": 44 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [50,46,15,16,48,7], "indexDifference": 1, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [5,6,8,5,6,3,1], "indexDifference": 0, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,6]

test_input = { "nums": [5,50,13,3,44,7,29], "indexDifference": 1, "valueDifference": 45 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [8,7,18,47,27,25,41], "indexDifference": 0, "valueDifference": 45 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [9,1,0,6,7,5,8], "indexDifference": 1, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [11,3,36,17,13,0,26], "indexDifference": 2, "valueDifference": 33 }
assert my_solution.findIndices(**test_input) == [2,5]

test_input = { "nums": [13,0,16,32,47,27,25], "indexDifference": 1, "valueDifference": 35 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [13,16,30,33,50,50,38], "indexDifference": 3, "valueDifference": 30 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [21,44,22,1,21,9,17], "indexDifference": 1, "valueDifference": 41 }
assert my_solution.findIndices(**test_input) == [1,3]

test_input = { "nums": [35,31,36,28,49,4,46], "indexDifference": 4, "valueDifference": 27 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [39,18,49,25,40,41,26], "indexDifference": 1, "valueDifference": 43 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [40,46,11,36,25,46,47], "indexDifference": 0, "valueDifference": 37 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [46,7,6,3,43,7,48], "indexDifference": 0, "valueDifference": 48 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0,1,6,8,8,3,9,10], "indexDifference": 2, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [1,0,6,4,8,7,2,5], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [3,8,3,8,0,5,5,7], "indexDifference": 4, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [5,10,4,4,8,6,0,4], "indexDifference": 2, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [1,6]

test_input = { "nums": [6,1,3,7,4,4,2,1], "indexDifference": 0, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [9,36,31,2,46,1,27,37], "indexDifference": 3, "valueDifference": 45 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [10,4,0,1,4,7,2,0], "indexDifference": 5, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,6]

test_input = { "nums": [26,20,19,36,20,28,33,39], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [29,3,30,34,25,40,10,37], "indexDifference": 5, "valueDifference": 22 }
assert my_solution.findIndices(**test_input) == [1,7]

test_input = { "nums": [39,26,46,9,5,34,0,20], "indexDifference": 0, "valueDifference": 24 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [46,12,38,21,12,9,18,29], "indexDifference": 3, "valueDifference": 35 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [1,7,7,2,4,10,1,5,9], "indexDifference": 4, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [2,4,1,5,2,0,3,5,7], "indexDifference": 5, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [2,5,6,5,9,7,2,3,6], "indexDifference": 4, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [2,6,9,4,9,4,10,9,2], "indexDifference": 0, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,1]


shortest-and-lexicographically-smallest-beautiful-string

Shortest and Lexicographically Smallest Beautiful String

Prompt:
"""
给你一个二进制字符串 s 和一个正整数 k 。

如果 s 的某个子字符串中 1 的个数恰好等于 k ，则称这个子字符串是一个 美丽子字符串 。

令 len 等于 最短 美丽子字符串的长度。

返回长度等于 len 且字典序 最小 的美丽子字符串。如果 s 中不含美丽子字符串，则返回一个 空 字符串。

对于相同长度的两个字符串 a 和 b ，如果在 a 和 b 出现不同的第一个位置上，a 中该位置上的字符严格大于 b 中的对应字符，则认为字符串 a 字典序 大于 字符串 b 。

 * 例如，"abcd" 的字典序大于 "abcc" ，因为两个字符串出现不同的第一个位置对应第四个字符，而 d 大于 c 。

示例 1：

输入：s = "100011001", k = 3
输出："11001"
解释：示例中共有 7 个美丽子字符串：
1. 子字符串 "100011001" 。
2. 子字符串 "100011001" 。
3. 子字符串 "100011001" 。
4. 子字符串 "100011001" 。
5. 子字符串 "100011001" 。
6. 子字符串 "100011001" 。
7. 子字符串 "100011001" 。
最短美丽子字符串的长度是 5 。
长度为 5 且字典序最小的美丽子字符串是子字符串 "11001" 。

示例 2：

输入：s = "1011", k = 2
输出："11"
解释：示例中共有 3 个美丽子字符串：
1. 子字符串 "1011" 。
2. 子字符串 "1011" 。
3. 子字符串 "1011" 。
最短美丽子字符串的长度是 2 。
长度为 2 且字典序最小的美丽子字符串是子字符串 "11" 。

示例 3：

输入：s = "000", k = 1
输出：""
解释：示例中不存在美丽子字符串。

提示：

 * 1 <= s.length <= 100
 * 1 <= k <= s.length
"""
class Solution:
    def shortestBeautifulSubstring(self, s: str, k: int) -> str:

给你一个二进制字符串 s 和一个正整数 k 。

如果 s 的某个子字符串中 1 的个数恰好等于 k ，则称这个子字符串是一个 美丽子字符串 。

令 len 等于 最短 美丽子字符串的长度。

返回长度等于 len 且字典序 最小 的美丽子字符串。如果 s 中不含美丽子字符串，则返回一个 空 字符串。

对于相同长度的两个字符串 a 和 b ，如果在 a 和 b 出现不同的第一个位置上，a 中该位置上的字符严格大于 b 中的对应字符，则认为字符串 a 字典序 大于 字符串 b 。

 * 例如，"abcd" 的字典序大于 "abcc" ，因为两个字符串出现不同的第一个位置对应第四个字符，而 d 大于 c 。

示例 1：

输入：s = "100011001", k = 3
输出："11001"
解释：示例中共有 7 个美丽子字符串：
1. 子字符串 "100011001" 。
2. 子字符串 "100011001" 。
3. 子字符串 "100011001" 。
4. 子字符串 "100011001" 。
5. 子字符串 "100011001" 。
6. 子字符串 "100011001" 。
7. 子字符串 "100011001" 。
最短美丽子字符串的长度是 5 。
长度为 5 且字典序最小的美丽子字符串是子字符串 "11001" 。

示例 2：

输入：s = "1011", k = 2
输出："11"
解释：示例中共有 3 个美丽子字符串：
1. 子字符串 "1011" 。
2. 子字符串 "1011" 。
3. 子字符串 "1011" 。
最短美丽子字符串的长度是 2 。
长度为 2 且字典序最小的美丽子字符串是子字符串 "11" 。

示例 3：

输入：s = "000", k = 1
输出：""
解释：示例中不存在美丽子字符串。

提示：

 * 1 <= s.length <= 100
 * 1 <= k <= s.length

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

```

my_solution = Solution()

test_input = { "s": "100011001", "k": 3 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11001"

test_input = { "s": "1011", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11"

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

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

test_input = { "s": "10100010", "k": 5 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "0010111", "k": 7 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "111111110010001010", "k": 11 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11111111001000101"

test_input = { "s": "00000110010011010110", "k": 13 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "1100001110111100100", "k": 8 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11101111001"

test_input = { "s": "01011101000111110", "k": 5 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11111"

test_input = { "s": "10001", "k": 5 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "001011010001101", "k": 11 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

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

test_input = { "s": "000110001", "k": 6 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

test_input = { "s": "100011000000000", "k": 9 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "10101000111", "k": 3 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "111"

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

test_input = { "s": "1100100101011001001", "k": 7 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "1100100101011"

test_input = { "s": "0001001", "k": 7 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "101100000", "k": 6 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "100011", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11"

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

test_input = { "s": "110000", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11"

test_input = { "s": "001110101101101111", "k": 10 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "10101101101111"

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

test_input = { "s": "1111111011111", "k": 12 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "1111111011111"

test_input = { "s": "0101111000101011001", "k": 9 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "101111000101011"

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

test_input = { "s": "01101101110110010", "k": 16 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "10111101011100101001", "k": 14 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

test_input = { "s": "0101001000001011011", "k": 12 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

test_input = { "s": "01001010010", "k": 6 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "01100110011101010", "k": 3 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "111"

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

test_input = { "s": "01010000110111110010", "k": 12 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "1101", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11"

test_input = { "s": "00000100000", "k": 9 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "10101101000111", "k": 3 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "111"

test_input = { "s": "101010111111110110", "k": 4 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "1111"

test_input = { "s": "0100111011101010", "k": 16 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

test_input = { "s": "000010110111011", "k": 8 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "10110111011"

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

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

test_input = { "s": "000100", "k": 5 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "1110001110100110011", "k": 13 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "111011001", "k": 9 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "0111000100001101", "k": 9 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "100011", "k": 5 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "111000101010010011", "k": 10 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "01010", "k": 5 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "0100100111100010", "k": 14 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

test_input = { "s": "111000", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11"

test_input = { "s": "101011", "k": 6 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "11101101110110111101", "k": 17 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "010011101", "k": 4 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11101"

test_input = { "s": "100111010111001", "k": 11 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "110001111100011", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11"

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

test_input = { "s": "11101110001111", "k": 7 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "1110001111"

test_input = { "s": "110", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11"

test_input = { "s": "110101", "k": 3 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "1101"

test_input = { "s": "0110100", "k": 7 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "00111", "k": 3 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "111"

test_input = { "s": "1011001100001110101", "k": 4 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11101"

test_input = { "s": "0101000010101010", "k": 6 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "10100001010101"

test_input = { "s": "0011000110001", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "11"

test_input = { "s": "01001011000110100", "k": 11 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

test_input = { "s": "00111100", "k": 5 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "1110", "k": 3 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "111"

test_input = { "s": "00010000110", "k": 9 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "110110100011", "k": 8 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "00111110001100000", "k": 7 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "1111100011"

test_input = { "s": "10100100101", "k": 11 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

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

test_input = { "s": "0101010101010111101", "k": 15 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

test_input = { "s": "110011010110", "k": 10 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

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

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

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

test_input = { "s": "101000", "k": 2 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "101"

test_input = { "s": "000010110010111", "k": 7 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "10110010111"

test_input = { "s": "0100111", "k": 4 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "100111"

test_input = { "s": "0111111100011111101", "k": 12 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "111111000111111"

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

test_input = { "s": "110110101010100000", "k": 10 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

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

test_input = { "s": "001101", "k": 6 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "01111001101001010101", "k": 16 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "00111010", "k": 6 }
assert my_solution.shortestBeautifulSubstring(**test_input) == ""

test_input = { "s": "11011101010100", "k": 7 }
assert my_solution.shortestBeautifulSubstring(**test_input) == "1101110101"


find-indices-with-index-and-value-difference-ii

Find Indices With Index and Value Difference II

Prompt:
"""
给你一个下标从 0 开始、长度为 n 的整数数组 nums ，以及整数 indexDifference 和整数 valueDifference 。

你的任务是从范围 [0, n - 1] 内找出  2 个满足下述所有条件的下标 i 和 j ：

 * abs(i - j) >= indexDifference 且
 * abs(nums[i] - nums[j]) >= valueDifference

返回整数数组 answer。如果存在满足题目要求的两个下标，则 answer = [i, j] ；否则，answer = [-1, -1] 。如果存在多组可供选择的下标对，只需要返回其中任意一组即可。

注意：i 和 j 可能 相等 。

示例 1：

输入：nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
输出：[0,3]
解释：在示例中，可以选择 i = 0 和 j = 3 。
abs(0 - 3) >= 2 且 abs(nums[0] - nums[3]) >= 4 。
因此，[0,3] 是一个符合题目要求的答案。
[3,0] 也是符合题目要求的答案。

示例 2：

输入：nums = [2,1], indexDifference = 0, valueDifference = 0
输出：[0,0]
解释：
在示例中，可以选择 i = 0 和 j = 0 。
abs(0 - 0) >= 0 且 abs(nums[0] - nums[0]) >= 0 。
因此，[0,0] 是一个符合题目要求的答案。
[0,1]、[1,0] 和 [1,1] 也是符合题目要求的答案。

示例 3：

输入：nums = [1,2,3], indexDifference = 2, valueDifference = 4
输出：[-1,-1]
解释：在示例中，可以证明无法找出 2 个满足所有条件的下标。
因此，返回 [-1,-1] 。

提示：

 * 1 <= n == nums.length <= 105
 * 0 <= nums[i] <= 109
 * 0 <= indexDifference <= 105
 * 0 <= valueDifference <= 109
"""
class Solution:
    def findIndices(self, nums: List[int], indexDifference: int, valueDifference: int) -> List[int]:

给你一个下标从 0 开始、长度为 n 的整数数组 nums ，以及整数 indexDifference 和整数 valueDifference 。

你的任务是从范围 [0, n - 1] 内找出  2 个满足下述所有条件的下标 i 和 j ：

 * abs(i - j) >= indexDifference 且
 * abs(nums[i] - nums[j]) >= valueDifference

返回整数数组 answer。如果存在满足题目要求的两个下标，则 answer = [i, j] ；否则，answer = [-1, -1] 。如果存在多组可供选择的下标对，只需要返回其中任意一组即可。

注意：i 和 j 可能 相等 。

示例 1：

输入：nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
输出：[0,3]
解释：在示例中，可以选择 i = 0 和 j = 3 。
abs(0 - 3) >= 2 且 abs(nums[0] - nums[3]) >= 4 。
因此，[0,3] 是一个符合题目要求的答案。
[3,0] 也是符合题目要求的答案。

示例 2：

输入：nums = [2,1], indexDifference = 0, valueDifference = 0
输出：[0,0]
解释：
在示例中，可以选择 i = 0 和 j = 0 。
abs(0 - 0) >= 0 且 abs(nums[0] - nums[0]) >= 0 。
因此，[0,0] 是一个符合题目要求的答案。
[0,1]、[1,0] 和 [1,1] 也是符合题目要求的答案。

示例 3：

输入：nums = [1,2,3], indexDifference = 2, valueDifference = 4
输出：[-1,-1]
解释：在示例中，可以证明无法找出 2 个满足所有条件的下标。
因此，返回 [-1,-1] 。

提示：

 * 1 <= n == nums.length <= 105
 * 0 <= nums[i] <= 109
 * 0 <= indexDifference <= 105
 * 0 <= valueDifference <= 109

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

```

my_solution = Solution()

test_input = { "nums": [5,1,4,1], "indexDifference": 2, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,3]

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

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

test_input = { "nums": [1], "indexDifference": 0, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [1], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [2], "indexDifference": 0, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [6], "indexDifference": 1, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [7], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [8], "indexDifference": 1, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [9], "indexDifference": 0, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [9], "indexDifference": 1, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [12], "indexDifference": 0, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [16], "indexDifference": 0, "valueDifference": 16 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [16], "indexDifference": 1, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [46], "indexDifference": 0, "valueDifference": 36 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0,10], "indexDifference": 2, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [2,7], "indexDifference": 2, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [5,1], "indexDifference": 2, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [5,12], "indexDifference": 0, "valueDifference": 10 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [8,0], "indexDifference": 1, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [8,4], "indexDifference": 1, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [9,8], "indexDifference": 0, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [15,8], "indexDifference": 0, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [20,21], "indexDifference": 1, "valueDifference": 14 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [23,47], "indexDifference": 2, "valueDifference": 47 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [32,14], "indexDifference": 1, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [36,14], "indexDifference": 2, "valueDifference": 11 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [40,12], "indexDifference": 1, "valueDifference": 20 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [45,41], "indexDifference": 2, "valueDifference": 21 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [50,24], "indexDifference": 1, "valueDifference": 18 }
assert my_solution.findIndices(**test_input) == [0,1]

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

test_input = { "nums": [3,9,3], "indexDifference": 0, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [3,12,40], "indexDifference": 0, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [4,10,8], "indexDifference": 0, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [5,27,26], "indexDifference": 1, "valueDifference": 15 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [7,8,10], "indexDifference": 2, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [8,2,6], "indexDifference": 1, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [8,7,5], "indexDifference": 2, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [9,5,4], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [9,9,8], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [10,4,10], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [10,5,2], "indexDifference": 2, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [37,45,23], "indexDifference": 1, "valueDifference": 28 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [37,49,25], "indexDifference": 1, "valueDifference": 29 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [45,32,30], "indexDifference": 2, "valueDifference": 45 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0,2,5,8], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [0,4,7,2], "indexDifference": 2, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,2]

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

test_input = { "nums": [1,8,6,10], "indexDifference": 2, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [2,0,9,2], "indexDifference": 2, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,4,8,3], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

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

test_input = { "nums": [9,9,7,7], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [10,33,39,15], "indexDifference": 1, "valueDifference": 12 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [22,28,50,25], "indexDifference": 0, "valueDifference": 28 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [36,35,45,34], "indexDifference": 1, "valueDifference": 31 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [50,21,32,5], "indexDifference": 0, "valueDifference": 26 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [0,6,2,10,4], "indexDifference": 3, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [0,8,2,5,10], "indexDifference": 0, "valueDifference": 10 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [0,9,0,5,9], "indexDifference": 3, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [0,9,4,9,9], "indexDifference": 0, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [3,7,7,10,10], "indexDifference": 2, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [0,3]

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

test_input = { "nums": [4,1,7,0,3], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [6,0,6,7,9], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [6,19,40,41,36], "indexDifference": 0, "valueDifference": 34 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,10,4,5,1], "indexDifference": 2, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [9,1,7,8,5], "indexDifference": 2, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [10,39,25,12,7], "indexDifference": 1, "valueDifference": 35 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [15,28,50,37,43], "indexDifference": 2, "valueDifference": 46 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0,6,6,0,0,6], "indexDifference": 2, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,2]

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

test_input = { "nums": [3,3,1,6,3,3], "indexDifference": 3, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [3,3,4,1,3,7], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [4,3,8,6,2,8], "indexDifference": 2, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [6,1,2,9,6,5], "indexDifference": 1, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [0,1]

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

test_input = { "nums": [6,7,0,2,2,6], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [7,6,3,5,9,5], "indexDifference": 2, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [2,4]

test_input = { "nums": [9,1,0,4,3,3], "indexDifference": 4, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [9,8,8,0,1,4], "indexDifference": 3, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [25,49,11,15,32,33], "indexDifference": 2, "valueDifference": 37 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0,44,42,26,15,37,23], "indexDifference": 0, "valueDifference": 17 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [3,5,3,44,8,47,10], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [3,8,8,0,2,0,10], "indexDifference": 4, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [5,1,0,7,5,2,0], "indexDifference": 4, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [9,10,1,3,1,5,0], "indexDifference": 2, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [13,3,15,48,32,19,33], "indexDifference": 1, "valueDifference": 25 }
assert my_solution.findIndices(**test_input) == [1,3]

test_input = { "nums": [29,12,42,16,50,22,10], "indexDifference": 2, "valueDifference": 29 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [30,48,12,15,43,17,13], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [31,33,46,4,13,45,37], "indexDifference": 0, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [43,37,25,44,45,21,47], "indexDifference": 1, "valueDifference": 37 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0,4,0,4,1,2,1,9], "indexDifference": 1, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,7]

test_input = { "nums": [0,7,3,2,6,1,7,4], "indexDifference": 4, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [2,10,2,0,6,0,7,7], "indexDifference": 2, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [1,3]

test_input = { "nums": [3,9,6,10,10,3,2,9], "indexDifference": 5, "valueDifference": 10 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [4,4,3,0,6,1,7,8], "indexDifference": 3, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [3,6]

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

test_input = { "nums": [6,5,6,3,0,10,9,8], "indexDifference": 2, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [1,3]

test_input = { "nums": [7,4,3,1,6,6,2,6], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]


construct-product-matrix

Construct Product Matrix

Prompt:
"""
给你一个下标从 0 开始、大小为 n * m 的二维整数矩阵 grid ，定义一个下标从 0 开始、大小为 n * m 的的二维矩阵 p。如果满足以下条件，则称 p 为 grid 的 乘积矩阵 ：

 * 对于每个元素 p[i][j] ，它的值等于除了 grid[i][j] 外所有元素的乘积。乘积对 12345 取余数。

返回 grid 的乘积矩阵。

示例 1：

输入：grid = [[1,2],[3,4]]
输出：[[24,12],[8,6]]
解释：p[0][0] = grid[0][1] * grid[1][0] * grid[1][1] = 2 * 3 * 4 = 24
p[0][1] = grid[0][0] * grid[1][0] * grid[1][1] = 1 * 3 * 4 = 12
p[1][0] = grid[0][0] * grid[0][1] * grid[1][1] = 1 * 2 * 4 = 8
p[1][1] = grid[0][0] * grid[0][1] * grid[1][0] = 1 * 2 * 3 = 6
所以答案是 [[24,12],[8,6]] 。

示例 2：

输入：grid = [[12345],[2],[1]]
输出：[[2],[0],[0]]
解释：p[0][0] = grid[0][1] * grid[0][2] = 2 * 1 = 2
p[0][1] = grid[0][0] * grid[0][2] = 12345 * 1 = 12345. 12345 % 12345 = 0 ，所以 p[0][1] = 0
p[0][2] = grid[0][0] * grid[0][1] = 12345 * 2 = 24690. 24690 % 12345 = 0 ，所以 p[0][2] = 0
所以答案是 [[2],[0],[0]] 。

提示：

 * 1 <= n == grid.length <= 105
 * 1 <= m == grid[i].length <= 105
 * 2 <= n * m <= 105
 * 1 <= grid[i][j] <= 109
"""
class Solution:
    def constructProductMatrix(self, grid: List[List[int]]) -> List[List[int]]:

my_solution = Solution()

test_input = { "grid": [[1,2],[3,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[24,12],[8,6]]

test_input = { "grid": [[12345],[2],[1]] }
assert my_solution.constructProductMatrix(**test_input) == [[2],[0],[0]]

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

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

test_input = { "grid": [[12345,12345]] }
assert my_solution.constructProductMatrix(**test_input) == [[0,0]]

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

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

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

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

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

test_input = { "grid": [[3],[5],[2]] }
assert my_solution.constructProductMatrix(**test_input) == [[10],[6],[15]]

test_input = { "grid": [[1,2],[1,1],[6,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[48,24],[48,48],[8,12]]

test_input = { "grid": [[1,2,2],[1,4,3]] }
assert my_solution.constructProductMatrix(**test_input) == [[48,24,24],[48,12,16]]

test_input = { "grid": [[2],[7],[2],[6]] }
assert my_solution.constructProductMatrix(**test_input) == [[84],[24],[84],[28]]

test_input = { "grid": [[3],[4],[7],[7]] }
assert my_solution.constructProductMatrix(**test_input) == [[196],[147],[84],[84]]

test_input = { "grid": [[3,1,1],[1,3,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[12,36,36],[36,12,9]]

test_input = { "grid": [[4],[8],[3],[7]] }
assert my_solution.constructProductMatrix(**test_input) == [[168],[84],[224],[96]]

test_input = { "grid": [[5],[8],[8],[3]] }
assert my_solution.constructProductMatrix(**test_input) == [[192],[120],[120],[320]]

test_input = { "grid": [[6],[5],[8],[5]] }
assert my_solution.constructProductMatrix(**test_input) == [[200],[240],[150],[240]]

test_input = { "grid": [[8],[1],[3],[8]] }
assert my_solution.constructProductMatrix(**test_input) == [[24],[192],[64],[24]]

test_input = { "grid": [[1],[10],[3],[10],[9]] }
assert my_solution.constructProductMatrix(**test_input) == [[2700],[270],[900],[270],[300]]

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

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

test_input = { "grid": [[1,2,3],[3,3,5],[3,4,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[6480,3240,2160],[2160,2160,1296],[2160,1620,3240]]

test_input = { "grid": [[2],[7],[5],[3],[4]] }
assert my_solution.constructProductMatrix(**test_input) == [[420],[120],[168],[280],[210]]

test_input = { "grid": [[2,2,2,2,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[8,8,8,8,16]]

test_input = { "grid": [[2,2,4,4],[3,2,1,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[768,768,384,384],[512,768,1536,384]]

test_input = { "grid": [[2,4,1,1],[3,4,4,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[192,96,384,384],[128,96,96,384]]

test_input = { "grid": [[3,1,1,4],[1,4,1,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[16,48,48,12],[48,12,48,48]]

test_input = { "grid": [[3,2,5],[6,4,3],[6,3,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[615,7095,7776],[6480,9720,615],[6480,615,1845]]

test_input = { "grid": [[5,5,5],[4,3,1],[4,5,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[6000,6000,6000],[7500,10000,5310],[7500,6000,5310]]

test_input = { "grid": [[6,3],[1,5],[2,7],[6,5]] }
assert my_solution.constructProductMatrix(**test_input) == [[6300,255],[765,7560],[6555,5400],[6300,7560]]

test_input = { "grid": [[6,3,2],[2,3,1],[5,5,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[3600,7200,10800],[10800,7200,9255],[4320,4320,5400]]

test_input = { "grid": [[6,5,3],[4,4,5],[3,2,5]] }
assert my_solution.constructProductMatrix(**test_input) == [[11310,6165,10275],[4620,4620,6165],[10275,9240,6165]]

test_input = { "grid": [[8],[5],[5],[9],[8]] }
assert my_solution.constructProductMatrix(**test_input) == [[1800],[2880],[2880],[1600],[1800]]

test_input = { "grid": [[10],[5],[6],[8],[6]] }
assert my_solution.constructProductMatrix(**test_input) == [[1440],[2880],[2400],[1800],[2400]]

test_input = { "grid": [[10],[9],[3],[4],[3]] }
assert my_solution.constructProductMatrix(**test_input) == [[324],[360],[1080],[810],[1080]]

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

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

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

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

test_input = { "grid": [[1,1,2,2,2,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[16,16,8,8,8,8]]

test_input = { "grid": [[1,1,3,3],[3,4,4,2],[6,6,3,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[2898,2898,966,966],[966,6897,6897,1449],[483,483,966,6897]]

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

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

test_input = { "grid": [[1,2,2,4,3],[3,4,1,4,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[4608,2304,2304,1152,1536],[1536,1152,4608,1152,2304]]

test_input = { "grid": [[1,3,1,3,1],[2,1,3,2,3]] }
assert my_solution.constructProductMatrix(**test_input) == [[324,108,324,108,324],[162,324,108,162,108]]

test_input = { "grid": [[1,3,3,3,4],[2,2,1,4,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[6912,2304,2304,2304,1728],[3456,3456,6912,1728,1728]]

test_input = { "grid": [[1,4,5],[1,3,2],[7,2,6],[6,2,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[7365,11100,11349],[7365,6570,9855],[9870,9855,3285],[3285,9855,9855]]

test_input = { "grid": [[1,6,6,4],[4,1,2,5],[5,4,6,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[12105,8190,8190,12285],[12285,12105,12225,4890],[4890,12285,8190,12225]]

test_input = { "grid": [[2,1,3,2,1],[3,1,3,1,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[108,216,72,108,216],[72,216,72,216,108]]

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

test_input = { "grid": [[2,2,2,2,1,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[16,16,16,16,32,16]]

test_input = { "grid": [[2,2,3,2,3],[3,1,3,2,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[2592,2592,1728,2592,1728],[1728,5184,1728,2592,1296]]

test_input = { "grid": [[2,3,4],[2,4,2],[1,8,1],[8,8,8]] }
assert my_solution.constructProductMatrix(**test_input) == [[8697,5798,10521],[8697,10521,8697],[5049,11433,5049],[11433,11433,11433]]

test_input = { "grid": [[2,4,4,5],[5,5,1,4],[4,2,2,5]] }
assert my_solution.constructProductMatrix(**test_input) == [[10405,11375,11375,9100],[9100,9100,8465,11375],[11375,10405,10405,9100]]

test_input = { "grid": [[3,4,1,1],[3,1,4,4],[1,5,1,5]] }
assert my_solution.constructProductMatrix(**test_input) == [[4800,3600,2055,2055],[4800,2055,3600,3600],[2055,2880,2055,2880]]

test_input = { "grid": [[3,4,6,3],[4,5,4,4],[5,2,6,3]] }
assert my_solution.constructProductMatrix(**test_input) == [[11625,11805,11985,11625],[11805,6975,11805,11805],[6975,11265,11985,11625]]

test_input = { "grid": [[4,1,4,4,4],[2,2,2,3,3]] }
assert my_solution.constructProductMatrix(**test_input) == [[4608,6087,4608,4608,4608],[9216,9216,9216,6144,6144]]

test_input = { "grid": [[4,8,8],[6,2,5],[7,3,7],[6,3,5]] }
assert my_solution.constructProductMatrix(**test_input) == [[3525,7935,7935],[6465,7050,2820],[7305,585,7305],[6465,585,2820]]

test_input = { "grid": [[6],[8],[2],[12],[6],[4]] }
assert my_solution.constructProductMatrix(**test_input) == [[4608],[3456],[1479],[2304],[4608],[6912]]

test_input = { "grid": [[6,2,5,2],[5,5,2,3],[4,6,5,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[3990,11970,12195,11970],[12195,12195,11970,7980],[5985,3990,12195,11970]]

test_input = { "grid": [[6,3,4,3],[6,4,2,5],[3,3,6,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[9795,7245,8520,7245],[9795,8520,4695,4347],[7245,7245,9795,9390]]

test_input = { "grid": [[6,5,6,6],[3,2,6,4],[1,3,4,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[2415,2898,2415,2415],[4830,7245,2415,9795],[2145,4830,9795,2145]]

test_input = { "grid": [[7],[11],[12],[7],[12],[7]] }
assert my_solution.constructProductMatrix(**test_input) == [[3546],[12],[8241],[3546],[8241],[3546]]

test_input = { "grid": [[7,4,5],[2,1,2],[5,3,8],[3,6,7]] }
assert my_solution.constructProductMatrix(**test_input) == [[12135,5805,2175],[11610,10875,11610],[2175,7740,9075],[7740,3870,12135]]

test_input = { "grid": [[8],[6],[7],[2],[7],[4]] }
assert my_solution.constructProductMatrix(**test_input) == [[2352],[3136],[2688],[9408],[2688],[4704]]

test_input = { "grid": [[8],[6],[7],[5],[3],[6]] }
assert my_solution.constructProductMatrix(**test_input) == [[3780],[5040],[4320],[6048],[10080],[5040]]

test_input = { "grid": [[8,1],[9,6],[2,4],[1,3],[3,6]] }
assert my_solution.constructProductMatrix(**test_input) == [[10983,1449],[8391,6414],[6897,9621],[1449,483],[483,6414]]

test_input = { "grid": [[8,4,3],[7,7,4],[1,2,3],[5,2,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[8955,5565,11535],[3180,3180,5565],[9915,11130,11535],[1983,11130,5565]]

test_input = { "grid": [[12],[8],[4],[3],[9],[5]] }
assert my_solution.constructProductMatrix(**test_input) == [[4320],[6480],[615],[4935],[5760],[10368]]

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

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

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

test_input = { "grid": [[1,1,6,5,6],[1,6,6,2,5],[3,4,1,1,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[11805,11805,12255,4830,12255],[11805,12255,12255,12075,4830],[12165,12210,11805,11805,12210]]

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

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

test_input = { "grid": [[1,3,1,2,1,2],[3,2,3,4,2,3]] }
assert my_solution.constructProductMatrix(**test_input) == [[5184,1728,5184,2592,5184,2592],[1728,2592,1728,1296,2592,1728]]

test_input = { "grid": [[1,3,5,2],[1,3,6,5],[8,1,2,7],[6,2,3,5]] }
assert my_solution.constructProductMatrix(**test_input) == [[2895,9195,10455,7620],[2895,9195,10770,10455],[1905,2895,7620,10995],[10770,7620,9195,10455]]

test_input = { "grid": [[1,4,4,4,3,3],[1,1,3,4,4,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[2958,6912,6912,6912,9216,9216],[2958,2958,9216,6912,6912,2958]]

test_input = { "grid": [[1,5,5,6],[4,7,6,1],[2,3,3,6],[3,6,3,7]] }
assert my_solution.constructProductMatrix(**test_input) == [[6570,11190,11190,1095],[7815,11520,1095,6570],[3285,2190,2190,1095],[2190,1095,2190,11520]]

test_input = { "grid": [[1,6,4,4,1],[6,2,5,1,4],[6,4,3,5,6]] }
assert my_solution.constructProductMatrix(**test_input) == [[3705,10905,10185,10185,3705],[10905,8025,3210,3705,10185],[10905,10185,9465,3210,10905]]

test_input = { "grid": [[1,7,2,8],[3,7,2,5],[2,3,5,6],[5,4,2,7]] }
assert my_solution.constructProductMatrix(**test_input) == [[4065,7635,8205,11310],[9585,7635,8205,8220],[8205,9585,8220,10965],[8220,10275,8205,7635]]

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

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

test_input = { "grid": [[2,1,2,2,2,2,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[32,64,32,32,32,32,32]]

test_input = { "grid": [[2,1,3,2,4,4],[1,3,2,2,4,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[4608,9216,3072,4608,2304,2304],[9216,3072,4608,4608,2304,9216]]

test_input = { "grid": [[2,2,2,2,1,2,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[16,16,16,16,32,16,32]]

test_input = { "grid": [[2,4,3,3,3,4],[3,1,4,3,4,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[966,483,8874,8874,8874,483],[8874,1932,483,8874,483,966]]

test_input = { "grid": [[2,5,4,8],[4,6,3,3],[1,5,1,4],[8,6,6,5]] }
assert my_solution.constructProductMatrix(**test_input) == [[30,4950,15,6180],[15,4125,8250,8250],[60,4950,60,15],[6180,4125,4125,4950]]

test_input = { "grid": [[2,7],[10,12],[2,4],[8,11],[2,12],[11,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[8340,5910],[6606,5505],[8340,4170],[2085,8250],[8340,5505],[8250,8340]]

test_input = { "grid": [[2,9],[1,4],[10,12],[2,7],[4,10],[10,8]] }
assert my_solution.constructProductMatrix(**test_input) == [[3435,10365],[6870,7890],[5625,10860],[3435,2745],[7890,5625],[5625,3945]]

test_input = { "grid": [[3],[9],[5],[1],[4],[14],[12]] }
assert my_solution.constructProductMatrix(**test_input) == [[5550],[10080],[5799],[4305],[10335],[6480],[7560]]

test_input = { "grid": [[3,2,2,2,4,3],[4,1,3,1,1,2]] }
assert my_solution.constructProductMatrix(**test_input) == [[2304,3456,3456,3456,1728,2304],[1728,6912,2304,6912,6912,3456]]

test_input = { "grid": [[3,2,4,2,2,3],[2,2,4,1,2,3]] }
assert my_solution.constructProductMatrix(**test_input) == [[9216,1479,6912,1479,1479,9216],[1479,1479,6912,2958,1479,9216]]

test_input = { "grid": [[3,6,2,2,5],[1,4,3,4,1],[4,5,2,4,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[7590,3795,11385,11385,2085],[10425,11865,7590,11865,10425],[11865,2085,11385,11865,11865]]

test_input = { "grid": [[4,1,5,4,5],[6,5,3,4,4],[3,2,6,2,3]] }
assert my_solution.constructProductMatrix(**test_input) == [[6945,3090,8025,6945,8025],[8745,8025,5145,6945,6945],[5145,1545,8745,1545,5145]]

test_input = { "grid": [[4,3,9],[3,9,10],[9,7,8],[8,4,7],[6,1,3]] }
assert my_solution.constructProductMatrix(**test_input) == [[3255,225,75],[225,75,11178],[75,1860,7800],[7800,3255,1860],[6285,675,225]]

test_input = { "grid": [[5,1,1,1,5],[3,4,2,6,6],[3,3,2,5,1]] }
assert my_solution.constructProductMatrix(**test_input) == [[6105,5835,5835,5835,6105],[6060,4545,9090,3030,3030],[6060,6060,9090,6105,5835]]

test_input = { "grid": [[5,3],[9,2],[2,6],[4,9],[12,2],[10,4]] }
assert my_solution.constructProductMatrix(**test_input) == [[1050,5865],[10185,2625],[2625,9105],[7485,10185],[10725,2625],[525,7485]]


last-visited-integers

Last Visited Integers

Prompt:
"""
给你一个下标从 0 开始的字符串数组 words ，其中 words[i] 要么是一个字符串形式的正整数，要么是字符串 "prev" 。

我们从数组的开头开始遍历，对于 words 中的每个 "prev" 字符串，找到 words 中的 上一个遍历的整数 ，定义如下：

 * k 表示到当前位置为止的连续 "prev" 字符串数目（包含当前字符串），令下标从 0 开始的 整数 数组 nums 表示目前为止遍历过的所有整数，同时用 nums_reverse 表示 nums 反转得到的数组，那么当前 "prev" 对应的 上一个遍历的整数 是 nums_reverse 数组中下标为 (k - 1) 的整数。
 * 如果 k 比目前为止遍历过的整数数目 更多 ，那么上一个遍历的整数为 -1 。

请你返回一个整数数组，包含所有上一个遍历的整数。

示例 1：

输入：words = ["1","2","prev","prev","prev"]
输出：[2,1,-1]
解释：
对于下标为 2 处的 "prev" ，上一个遍历的整数是 2 ，因为连续 "prev" 数目为 1 ，同时在数组 reverse_nums 中，第一个元素是 2 。
对于下标为 3 处的 "prev" ，上一个遍历的整数是 1 ，因为连续 "prev" 数目为 2 ，同时在数组 reverse_nums 中，第二个元素是 1 。
对于下标为 4 处的 "prev" ，上一个遍历的整数是 -1 ，因为连续 "prev" 数目为 3 ，但总共只遍历过 2 个整数。

示例 2：

输入：words = ["1","prev","2","prev","prev"]
输出：[1,2,1]
解释：
对于下标为 1 处的 "prev" ，上一个遍历的整数是 1 。
对于下标为 3 处的 "prev" ，上一个遍历的整数是 2 。
对于下标为 4 处的 "prev" ，上一个遍历的整数是 1 ，因为连续 "prev" 数目为 2 ，同时在数组 reverse_nums 中，第二个元素是 1 。

提示：

 * 1 <= words.length <= 100
 * words[i] == "prev" 或 1 <= int(words[i]) <= 100
"""
class Solution:
    def lastVisitedIntegers(self, words: List[str]) -> List[int]:

给你一个下标从 0 开始的字符串数组 words ，其中 words[i] 要么是一个字符串形式的正整数，要么是字符串 "prev" 。

我们从数组的开头开始遍历，对于 words 中的每个 "prev" 字符串，找到 words 中的 上一个遍历的整数 ，定义如下：

 * k 表示到当前位置为止的连续 "prev" 字符串数目（包含当前字符串），令下标从 0 开始的 整数 数组 nums 表示目前为止遍历过的所有整数，同时用 nums_reverse 表示 nums 反转得到的数组，那么当前 "prev" 对应的 上一个遍历的整数 是 nums_reverse 数组中下标为 (k - 1) 的整数。
 * 如果 k 比目前为止遍历过的整数数目 更多 ，那么上一个遍历的整数为 -1 。

请你返回一个整数数组，包含所有上一个遍历的整数。

示例 1：

输入：words = ["1","2","prev","prev","prev"]
输出：[2,1,-1]
解释：
对于下标为 2 处的 "prev" ，上一个遍历的整数是 2 ，因为连续 "prev" 数目为 1 ，同时在数组 reverse_nums 中，第一个元素是 2 。
对于下标为 3 处的 "prev" ，上一个遍历的整数是 1 ，因为连续 "prev" 数目为 2 ，同时在数组 reverse_nums 中，第二个元素是 1 。
对于下标为 4 处的 "prev" ，上一个遍历的整数是 -1 ，因为连续 "prev" 数目为 3 ，但总共只遍历过 2 个整数。

示例 2：

输入：words = ["1","prev","2","prev","prev"]
输出：[1,2,1]
解释：
对于下标为 1 处的 "prev" ，上一个遍历的整数是 1 。
对于下标为 3 处的 "prev" ，上一个遍历的整数是 2 。
对于下标为 4 处的 "prev" ，上一个遍历的整数是 1 ，因为连续 "prev" 数目为 2 ，同时在数组 reverse_nums 中，第二个元素是 1 。

提示：

 * 1 <= words.length <= 100
 * words[i] == "prev" 或 1 <= int(words[i]) <= 100

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

```

my_solution = Solution()

test_input = { "words": ["1","2","prev","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [2,1,-1]

test_input = { "words": ["1","prev","2","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [1,2,1]

test_input = { "words": ["prev","prev","prev","27"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1]

test_input = { "words": ["17","42"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1]

test_input = { "words": ["prev","prev","prev","52","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,52]

test_input = { "words": ["prev","prev","68","prev","prev","53","40","23","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,68,-1,23]

test_input = { "words": ["99","23","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [23]

test_input = { "words": ["prev","prev","prev","58","99","prev","10","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,99,10]

test_input = { "words": ["prev","51","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,51,-1]

test_input = { "words": ["prev","46","9","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,9]

test_input = { "words": ["prev","prev","prev","prev","prev","26"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,-1,-1]

test_input = { "words": ["prev","21","prev","76","82","prev","96","prev","57","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,21,82,96,57]

test_input = { "words": ["52","4","prev","prev","prev","69"] }
assert my_solution.lastVisitedIntegers(**test_input) == [4,52,-1]

test_input = { "words": ["24","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [24]

test_input = { "words": ["46","prev","78","prev","83","21","prev","94","50"] }
assert my_solution.lastVisitedIntegers(**test_input) == [46,78,21]

test_input = { "words": ["14","66","prev","prev","46","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [66,14,46]

test_input = { "words": ["35","90"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["prev","9","prev","8","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,9,8]

test_input = { "words": ["prev","prev","88","71","47","65","24","39"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1]

test_input = { "words": ["45","73","78","2","54","prev","85","62","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [54,62]

test_input = { "words": ["prev","prev","80","9","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,9]

test_input = { "words": ["79","19","prev","prev","prev","67","prev","16","2"] }
assert my_solution.lastVisitedIntegers(**test_input) == [19,79,-1,67]

test_input = { "words": ["94","prev","prev","prev","prev","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [94,-1,-1,-1,-1,-1]

test_input = { "words": ["prev","prev","prev","82","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,82]

test_input = { "words": ["94","14","81","43","prev","43","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [43,43]

test_input = { "words": ["prev","prev","94","56","prev","32","prev","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,56,32,56,94]

test_input = { "words": ["93"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["46","91","3","40","31","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [31]

test_input = { "words": ["41","prev","17","58","78"] }
assert my_solution.lastVisitedIntegers(**test_input) == [41]

test_input = { "words": ["prev","prev","82","41","96","89","71"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1]

test_input = { "words": ["4","prev","50","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [4,50,4]

test_input = { "words": ["59","76","prev","29","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [76,29]

test_input = { "words": ["prev","62"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1]

test_input = { "words": ["6","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [6]

test_input = { "words": ["prev","prev","prev","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,-1,-1]

test_input = { "words": ["28","5","35","prev","41","27","70","65","84"] }
assert my_solution.lastVisitedIntegers(**test_input) == [35]

test_input = { "words": ["94","45","prev","61"] }
assert my_solution.lastVisitedIntegers(**test_input) == [45]

test_input = { "words": ["prev","34","prev","prev","prev","prev","21","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,34,-1,-1,-1,21]

test_input = { "words": ["prev","12","100","33","prev","85","93"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,33]

test_input = { "words": ["26"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["27","prev","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [27,-1,-1]

test_input = { "words": ["prev","prev","22","33","prev","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,33,22,-1]

test_input = { "words": ["30","prev","87","prev","19","prev","8","prev","81"] }
assert my_solution.lastVisitedIntegers(**test_input) == [30,87,19,8]

test_input = { "words": ["35","prev","47","82","86","84","prev","76","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [35,84,76]

test_input = { "words": ["prev","87"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1]

test_input = { "words": ["prev","69","78","prev","prev","16"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,78,69]

test_input = { "words": ["22","97","prev","2"] }
assert my_solution.lastVisitedIntegers(**test_input) == [97]

test_input = { "words": ["72","74"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["84","prev","prev","21"] }
assert my_solution.lastVisitedIntegers(**test_input) == [84,-1]

test_input = { "words": ["64","24"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["17","prev","59","prev","51","11","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [17,59,11,51]

test_input = { "words": ["57","prev","27","30","prev","prev","75"] }
assert my_solution.lastVisitedIntegers(**test_input) == [57,30,27]

test_input = { "words": ["65","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [65,-1]

test_input = { "words": ["prev","53","76","54","94","77"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1]

test_input = { "words": ["89","51","prev","prev","12","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [51,89,12,51]

test_input = { "words": ["prev","28","25","prev","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,25,28,-1]

test_input = { "words": ["51","prev","prev","76"] }
assert my_solution.lastVisitedIntegers(**test_input) == [51,-1]

test_input = { "words": ["2","24","63","prev","43","19","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [63,19]

test_input = { "words": ["prev","38","1"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1]

test_input = { "words": ["56","75","prev","prev","94"] }
assert my_solution.lastVisitedIntegers(**test_input) == [75,56]

test_input = { "words": ["prev","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1]

test_input = { "words": ["prev","37","25","31","prev","prev","42"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,31,25]

test_input = { "words": ["73","30","prev","20","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [30,20,30]

test_input = { "words": ["85","prev","prev","78","prev","100","8","17","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [85,-1,78,17]

test_input = { "words": ["prev","55","prev","87","19","prev","13","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,55,19,13,19]

test_input = { "words": ["prev","prev","5","prev","prev","prev","80","17"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,5,-1,-1]

test_input = { "words": ["100","3","prev","prev","93","35","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [3,100,35,93]

test_input = { "words": ["75","7"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["prev","prev","prev","prev","prev","prev","71","prev","27"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,-1,-1,-1,71]

test_input = { "words": ["prev","prev","prev","91","44","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,44]

test_input = { "words": ["prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1]

test_input = { "words": ["11","prev","87","prev","prev","94","prev","68"] }
assert my_solution.lastVisitedIntegers(**test_input) == [11,87,11,94]

test_input = { "words": ["78"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["prev","prev","73","prev","prev","27","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,73,-1,27]

test_input = { "words": ["prev","70","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,70,-1]

test_input = { "words": ["68","prev","38","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [68,38,68]

test_input = { "words": ["prev","prev","36"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1]

test_input = { "words": ["prev","prev","36","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,36]

test_input = { "words": ["18","58","41","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [41,58]

test_input = { "words": ["prev","prev","35"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1]

test_input = { "words": ["prev","72","prev","96","9","50","prev","52"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,72,50]

test_input = { "words": ["92","95","47","48","prev","50","34","prev","prev","46"] }
assert my_solution.lastVisitedIntegers(**test_input) == [48,34,50]

test_input = { "words": ["36","88","15","99","48"] }
assert my_solution.lastVisitedIntegers(**test_input) == []

test_input = { "words": ["93","prev","2","58","83","90","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [93,90]

test_input = { "words": ["prev","68","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,68]

test_input = { "words": ["prev","56","prev","prev","36","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,56,-1,36]

test_input = { "words": ["53","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [53]

test_input = { "words": ["5","29","94","3","48","prev","59","90","prev","69"] }
assert my_solution.lastVisitedIntegers(**test_input) == [48,90]

test_input = { "words": ["89","prev","prev","75","prev","98","80","prev","68","33"] }
assert my_solution.lastVisitedIntegers(**test_input) == [89,-1,75,80]

test_input = { "words": ["prev","93","prev","74","33"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,93]

test_input = { "words": ["prev","prev","10","25","prev","54","prev","prev","prev","76"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,25,54,25,10]

test_input = { "words": ["9","prev","14","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [9,14]

test_input = { "words": ["prev","prev","prev","18","66","92","prev","87","85","25"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,92]

test_input = { "words": ["prev","prev","prev","16","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,-1,16]

test_input = { "words": ["prev","prev","99","prev","82","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,99,82,99]

test_input = { "words": ["prev","5","90","71","prev","prev","61"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,71,90]

test_input = { "words": ["prev","prev","71","54","prev","20","65","prev","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,54,65,20]

test_input = { "words": ["prev","85","prev","93","prev","98","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,85,93,98]

test_input = { "words": ["prev","prev","34","prev"] }
assert my_solution.lastVisitedIntegers(**test_input) == [-1,-1,34]