shortest-and-lexicographically-smallest-beautiful-string

Shortest and Lexicographically Smallest Beautiful String

Prompt:
"""
You are given a binary string s and a positive integer k.

A substring of s is beautiful if the number of 1's in it is exactly k.

Let len be the length of the shortest beautiful substring.

Return the lexicographically smallest beautiful substring of string s with length equal to len. If s doesn't contain a beautiful substring, return an empty string.

A string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b.

 * For example, "abcd" is lexicographically larger than "abcc" because the first position they differ is at the fourth character, and d is greater than c.

Example 1:

Input: s = "100011001", k = 3
Output: "11001"
Explanation: There are 7 beautiful substrings in this example:
1. The substring "100011001".
2. The substring "100011001".
3. The substring "100011001".
4. The substring "100011001".
5. The substring "100011001".
6. The substring "100011001".
7. The substring "100011001".
The length of the shortest beautiful substring is 5.
The lexicographically smallest beautiful substring with length 5 is the substring "11001".

Example 2:

Input: s = "1011", k = 2
Output: "11"
Explanation: There are 3 beautiful substrings in this example:
1. The substring "1011".
2. The substring "1011".
3. The substring "1011".
The length of the shortest beautiful substring is 2.
The lexicographically smallest beautiful substring with length 2 is the substring "11".

Example 3:

Input: s = "000", k = 1
Output: ""
Explanation: There are no beautiful substrings in this example.

Constraints:

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

You are given a binary string s and a positive integer k.

A substring of s is beautiful if the number of 1's in it is exactly k.

Let len be the length of the shortest beautiful substring.

Return the lexicographically smallest beautiful substring of string s with length equal to len. If s doesn't contain a beautiful substring, return an empty string.

A string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b.

 * For example, "abcd" is lexicographically larger than "abcc" because the first position they differ is at the fourth character, and d is greater than c.

Example 1:

Input: s = "100011001", k = 3
Output: "11001"
Explanation: There are 7 beautiful substrings in this example:
1. The substring "100011001".
2. The substring "100011001".
3. The substring "100011001".
4. The substring "100011001".
5. The substring "100011001".
6. The substring "100011001".
7. The substring "100011001".
The length of the shortest beautiful substring is 5.
The lexicographically smallest beautiful substring with length 5 is the substring "11001".

Example 2:

Input: s = "1011", k = 2
Output: "11"
Explanation: There are 3 beautiful substrings in this example:
1. The substring "1011".
2. The substring "1011".
3. The substring "1011".
The length of the shortest beautiful substring is 2.
The lexicographically smallest beautiful substring with length 2 is the substring "11".

Example 3:

Input: s = "000", k = 1
Output: ""
Explanation: There are no beautiful substrings in this example.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.

Your task is to find two indices i and j, both in the range [0, n - 1], that satisfy the following conditions:

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

Return an integer array answer, where answer = [i, j] if there are two such indices, and answer = [-1, -1] otherwise. If there are multiple choices for the two indices, return any of them.

Note: i and j may be equal.

Example 1:

Input: nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
Output: [0,3]
Explanation: In this example, i = 0 and j = 3 can be selected.
abs(0 - 3) >= 2 and abs(nums[0] - nums[3]) >= 4.
Hence, a valid answer is [0,3].
[3,0] is also a valid answer.

Example 2:

Input: nums = [2,1], indexDifference = 0, valueDifference = 0
Output: [0,0]
Explanation: In this example, i = 0 and j = 0 can be selected.
abs(0 - 0) >= 0 and abs(nums[0] - nums[0]) >= 0.
Hence, a valid answer is [0,0].
Other valid answers are [0,1], [1,0], and [1,1].

Example 3:

Input: nums = [1,2,3], indexDifference = 2, valueDifference = 4
Output: [-1,-1]
Explanation: In this example, it can be shown that it is impossible to find two indices that satisfy both conditions.
Hence, [-1,-1] is returned.

Constraints:

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

You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.

Your task is to find two indices i and j, both in the range [0, n - 1], that satisfy the following conditions:

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

Return an integer array answer, where answer = [i, j] if there are two such indices, and answer = [-1, -1] otherwise. If there are multiple choices for the two indices, return any of them.

Note: i and j may be equal.

Example 1:

Input: nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
Output: [0,3]
Explanation: In this example, i = 0 and j = 3 can be selected.
abs(0 - 3) >= 2 and abs(nums[0] - nums[3]) >= 4.
Hence, a valid answer is [0,3].
[3,0] is also a valid answer.

Example 2:

Input: nums = [2,1], indexDifference = 0, valueDifference = 0
Output: [0,0]
Explanation: In this example, i = 0 and j = 0 can be selected.
abs(0 - 0) >= 0 and abs(nums[0] - nums[0]) >= 0.
Hence, a valid answer is [0,0].
Other valid answers are [0,1], [1,0], and [1,1].

Example 3:

Input: nums = [1,2,3], indexDifference = 2, valueDifference = 4
Output: [-1,-1]
Explanation: In this example, it can be shown that it is impossible to find two indices that satisfy both conditions.
Hence, [-1,-1] is returned.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
Given a 0-indexed 2D integer matrix grid of size n * m, we define a 0-indexed 2D matrix p of size n * m as the product matrix of grid if the following condition is met:

 * Each element p[i][j] is calculated as the product of all elements in grid except for the element grid[i][j]. This product is then taken modulo 12345.

Return the product matrix of grid.

Example 1:

Input: grid = [[1,2],[3,4]]
Output: [[24,12],[8,6]]
Explanation: 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
So the answer is [[24,12],[8,6]].

Example 2:

Input: grid = [[12345],[2],[1]]
Output: [[2],[0],[0]]
Explanation: 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. So p[0][1] = 0.
p[0][2] = grid[0][0] * grid[0][1] = 12345 * 2 = 24690. 24690 % 12345 = 0. So p[0][2] = 0.
So the answer is [[2],[0],[0]].

Constraints:

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

Given a 0-indexed 2D integer matrix grid of size n * m, we define a 0-indexed 2D matrix p of size n * m as the product matrix of grid if the following condition is met:

 * Each element p[i][j] is calculated as the product of all elements in grid except for the element grid[i][j]. This product is then taken modulo 12345.

Return the product matrix of grid.

Example 1:

Input: grid = [[1,2],[3,4]]
Output: [[24,12],[8,6]]
Explanation: 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
So the answer is [[24,12],[8,6]].

Example 2:

Input: grid = [[12345],[2],[1]]
Output: [[2],[0],[0]]
Explanation: 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. So p[0][1] = 0.
p[0][2] = grid[0][0] * grid[0][1] = 12345 * 2 = 24690. 24690 % 12345 = 0. So p[0][2] = 0.
So the answer is [[2],[0],[0]].

Constraints:

 * 1 <= n == grid.length <= 105
 * 1 <= m == grid[i].length <= 105
 * 2 <= n * m <= 105
 * 1 <= grid[i][j] <= 109

Please complete the code below to solve above prblem:
```python
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:
"""
Given a 0-indexed array of strings words where words[i] is either a positive integer represented as a string or the string "prev".

Start iterating from the beginning of the array; for every "prev" string seen in words, find the last visited integer in words which is defined as follows:

 * Let k be the number of consecutive "prev" strings seen so far (containing the current string). Let nums be the 0-indexed array of integers seen so far and nums_reverse be the reverse of nums, then the integer at (k - 1)th index of nums_reverse will be the last visited integer for this "prev".
 * If k is greater than the total visited integers, then the last visited integer will be -1.

Return an integer array containing the last visited integers.

Example 1:

Input: words = ["1","2","prev","prev","prev"]
Output: [2,1,-1]
Explanation:
For "prev" at index = 2, last visited integer will be 2 as here the number of consecutive "prev" strings is 1, and in the array reverse_nums, 2 will be the first element.
For "prev" at index = 3, last visited integer will be 1 as there are a total of two consecutive "prev" strings including this "prev" which are visited, and 1 is the second last visited integer.
For "prev" at index = 4, last visited integer will be -1 as there are a total of three consecutive "prev" strings including this "prev" which are visited, but the total number of integers visited is two.

Example 2:

Input: words = ["1","prev","2","prev","prev"]
Output: [1,2,1]
Explanation:
For "prev" at index = 1, last visited integer will be 1.
For "prev" at index = 3, last visited integer will be 2.
For "prev" at index = 4, last visited integer will be 1 as there are a total of two consecutive "prev" strings including this "prev" which are visited, and 1 is the second last visited integer.

Constraints:

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

Given a 0-indexed array of strings words where words[i] is either a positive integer represented as a string or the string "prev".

Start iterating from the beginning of the array; for every "prev" string seen in words, find the last visited integer in words which is defined as follows:

 * Let k be the number of consecutive "prev" strings seen so far (containing the current string). Let nums be the 0-indexed array of integers seen so far and nums_reverse be the reverse of nums, then the integer at (k - 1)th index of nums_reverse will be the last visited integer for this "prev".
 * If k is greater than the total visited integers, then the last visited integer will be -1.

Return an integer array containing the last visited integers.

Example 1:

Input: words = ["1","2","prev","prev","prev"]
Output: [2,1,-1]
Explanation:
For "prev" at index = 2, last visited integer will be 2 as here the number of consecutive "prev" strings is 1, and in the array reverse_nums, 2 will be the first element.
For "prev" at index = 3, last visited integer will be 1 as there are a total of two consecutive "prev" strings including this "prev" which are visited, and 1 is the second last visited integer.
For "prev" at index = 4, last visited integer will be -1 as there are a total of three consecutive "prev" strings including this "prev" which are visited, but the total number of integers visited is two.

Example 2:

Input: words = ["1","prev","2","prev","prev"]
Output: [1,2,1]
Explanation:
For "prev" at index = 1, last visited integer will be 1.
For "prev" at index = 3, last visited integer will be 2.
For "prev" at index = 4, last visited integer will be 1 as there are a total of two consecutive "prev" strings including this "prev" which are visited, and 1 is the second last visited integer.

Constraints:

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

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


longest-unequal-adjacent-groups-subsequence-i

Longest Unequal Adjacent Groups Subsequence I

Prompt:
"""
You are given an integer n, a 0-indexed string array words, and a 0-indexed binary array groups, both arrays having length n.

You need to select the longest subsequence from an array of indices [0, 1, ..., n - 1], such that for the subsequence denoted as [i0, i1, ..., ik - 1] having length k, groups[ij] != groups[ij + 1], for each j where 0 < j + 1 < k.

Return a string array containing the words corresponding to the indices (in order) in the selected subsequence. If there are multiple answers, return any of them.

A subsequence of an array is a new array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.

Note: strings in words may be unequal in length.

Example 1:

Input: n = 3, words = ["e","a","b"], groups = [0,0,1]
Output: ["e","b"]
Explanation: A subsequence that can be selected is [0,2] because groups[0] != groups[2].
So, a valid answer is [words[0],words[2]] = ["e","b"].
Another subsequence that can be selected is [1,2] because groups[1] != groups[2].
This results in [words[1],words[2]] = ["a","b"].
It is also a valid answer.
It can be shown that the length of the longest subsequence of indices that satisfies the condition is 2.

Example 2:

Input: n = 4, words = ["a","b","c","d"], groups = [1,0,1,1]
Output: ["a","b","c"]
Explanation: A subsequence that can be selected is [0,1,2] because groups[0] != groups[1] and groups[1] != groups[2].
So, a valid answer is [words[0],words[1],words[2]] = ["a","b","c"].
Another subsequence that can be selected is [0,1,3] because groups[0] != groups[1] and groups[1] != groups[3].
This results in [words[0],words[1],words[3]] = ["a","b","d"].
It is also a valid answer.
It can be shown that the length of the longest subsequence of indices that satisfies the condition is 3.

Constraints:

 * 1 <= n == words.length == groups.length <= 100
 * 1 <= words[i].length <= 10
 * 0 <= groups[i] < 2
 * words consists of distinct strings.
 * words[i] consists of lowercase English letters.
"""
class Solution:
    def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:

You are given an integer n, a 0-indexed string array words, and a 0-indexed binary array groups, both arrays having length n.

You need to select the longest subsequence from an array of indices [0, 1, ..., n - 1], such that for the subsequence denoted as [i0, i1, ..., ik - 1] having length k, groups[ij] != groups[ij + 1], for each j where 0 < j + 1 < k.

Return a string array containing the words corresponding to the indices (in order) in the selected subsequence. If there are multiple answers, return any of them.

A subsequence of an array is a new array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.

Note: strings in words may be unequal in length.

Example 1:

Input: n = 3, words = ["e","a","b"], groups = [0,0,1]
Output: ["e","b"]
Explanation: A subsequence that can be selected is [0,2] because groups[0] != groups[2].
So, a valid answer is [words[0],words[2]] = ["e","b"].
Another subsequence that can be selected is [1,2] because groups[1] != groups[2].
This results in [words[1],words[2]] = ["a","b"].
It is also a valid answer.
It can be shown that the length of the longest subsequence of indices that satisfies the condition is 2.

Example 2:

Input: n = 4, words = ["a","b","c","d"], groups = [1,0,1,1]
Output: ["a","b","c"]
Explanation: A subsequence that can be selected is [0,1,2] because groups[0] != groups[1] and groups[1] != groups[2].
So, a valid answer is [words[0],words[1],words[2]] = ["a","b","c"].
Another subsequence that can be selected is [0,1,3] because groups[0] != groups[1] and groups[1] != groups[3].
This results in [words[0],words[1],words[3]] = ["a","b","d"].
It is also a valid answer.
It can be shown that the length of the longest subsequence of indices that satisfies the condition is 3.

Constraints:

 * 1 <= n == words.length == groups.length <= 100
 * 1 <= words[i].length <= 10
 * 0 <= groups[i] < 2
 * words consists of distinct strings.
 * words[i] consists of lowercase English letters.

Please complete the code below to solve above prblem:
```python
class Solution:
    def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:

```

my_solution = Solution()

test_input = { "n": 3, "words": ["e","a","b"], "groups": [0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["e","b"]

test_input = { "n": 4, "words": ["a","b","c","d"], "groups": [1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["a","b","c"]

test_input = { "n": 1, "words": ["c"], "groups": [0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c"]

test_input = { "n": 1, "words": ["d"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["d"]

test_input = { "n": 1, "words": ["e"], "groups": [0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["e"]

test_input = { "n": 1, "words": ["fe"], "groups": [0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["fe"]

test_input = { "n": 1, "words": ["frl"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["frl"]

test_input = { "n": 1, "words": ["ha"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ha"]

test_input = { "n": 1, "words": ["l"], "groups": [0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["l"]

test_input = { "n": 1, "words": ["n"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n"]

test_input = { "n": 1, "words": ["s"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["s"]

test_input = { "n": 2, "words": ["d","g"], "groups": [0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["d","g"]

test_input = { "n": 2, "words": ["lr","h"], "groups": [0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["lr"]

test_input = { "n": 2, "words": ["wx","h"], "groups": [0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["wx","h"]

test_input = { "n": 2, "words": ["yw","n"], "groups": [0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["yw","n"]

test_input = { "n": 2, "words": ["z","n"], "groups": [0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["z"]

test_input = { "n": 2, "words": ["zr","a"], "groups": [0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["zr"]

test_input = { "n": 3, "words": ["h","vv","kp"], "groups": [0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["h","vv","kp"]

test_input = { "n": 3, "words": ["m","v","y"], "groups": [0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["m","v","y"]

test_input = { "n": 3, "words": ["o","cfy","en"], "groups": [1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["o","cfy"]

test_input = { "n": 3, "words": ["tu","rv","bn"], "groups": [0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["tu"]

test_input = { "n": 4, "words": ["c","f","y","i"], "groups": [1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c","f","y"]

test_input = { "n": 4, "words": ["c","w","h","s"], "groups": [0,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c","s"]

test_input = { "n": 4, "words": ["d","a","v","b"], "groups": [1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["d","a","b"]

test_input = { "n": 4, "words": ["hh","svj","a","nr"], "groups": [1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["hh"]

test_input = { "n": 4, "words": ["im","j","xq","cjs"], "groups": [1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["im","j","cjs"]

test_input = { "n": 4, "words": ["m","dkg","r","h"], "groups": [1,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["m","h"]

test_input = { "n": 4, "words": ["ow","qay","r","j"], "groups": [1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ow"]

test_input = { "n": 4, "words": ["r","k","pb","x"], "groups": [0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["r","pb","x"]

test_input = { "n": 4, "words": ["sq","do","bcj","nm"], "groups": [0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["sq","do","nm"]

test_input = { "n": 4, "words": ["sz","mq","j","u"], "groups": [0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["sz","j","u"]

test_input = { "n": 4, "words": ["x","nf","p","asn"], "groups": [1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["x"]

test_input = { "n": 4, "words": ["z","tkt","x","swy"], "groups": [1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["z","tkt","x"]

test_input = { "n": 5, "words": ["ht","lw","ax","vi","fo"], "groups": [0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ht","ax","vi"]

test_input = { "n": 5, "words": ["mc","kh","x","q","z"], "groups": [0,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["mc","x","z"]

test_input = { "n": 5, "words": ["n","fg","fy","tv","gv"], "groups": [1,1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n"]

test_input = { "n": 5, "words": ["n","l","e","d","m"], "groups": [1,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n","e","d"]

test_input = { "n": 5, "words": ["n","m","g","b","d"], "groups": [0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n","g","b"]

test_input = { "n": 5, "words": ["nz","zwt","hig","s","jze"], "groups": [1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["nz","s","jze"]

test_input = { "n": 5, "words": ["o","i","b","k","kz"], "groups": [0,0,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["o","b"]

test_input = { "n": 5, "words": ["r","o","k","d","f"], "groups": [0,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["r","d"]

test_input = { "n": 5, "words": ["sfh","exd","j","w","gc"], "groups": [1,0,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["sfh","exd","j"]

test_input = { "n": 5, "words": ["v","f","k","l","p"], "groups": [0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["v","k","l"]

test_input = { "n": 5, "words": ["vbd","ua","muo","mu","qi"], "groups": [0,0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["vbd","mu","qi"]

test_input = { "n": 5, "words": ["we","ch","tl","yx","utx"], "groups": [1,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["we","ch","yx"]

test_input = { "n": 5, "words": ["x","vlk","tds","dfn","kr"], "groups": [0,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["x","tds","kr"]

test_input = { "n": 5, "words": ["y","j","u","r","f"], "groups": [0,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","u","f"]

test_input = { "n": 5, "words": ["y","r","z","x","q"], "groups": [0,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","r","z","x"]

test_input = { "n": 5, "words": ["yc","fgq","gg","og","tca"], "groups": [0,1,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["yc","fgq","tca"]

test_input = { "n": 5, "words": ["z","d","p","c","m"], "groups": [0,0,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["z"]

test_input = { "n": 6, "words": ["c","i","to","kv","op","u"], "groups": [0,0,1,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c","to","kv"]

test_input = { "n": 6, "words": ["d","h","e","k","j","r"], "groups": [0,1,1,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["d","h","k","j","r"]

test_input = { "n": 6, "words": ["l","f","v","b","w","k"], "groups": [1,0,1,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["l","f","v","w"]

test_input = { "n": 6, "words": ["lj","vf","pa","w","z","q"], "groups": [0,0,1,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["lj","pa","w"]

test_input = { "n": 7, "words": ["cd","oki","ho","oi","m","yvy","i"], "groups": [1,1,0,1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cd","ho","oi"]

test_input = { "n": 7, "words": ["exb","c","oq","lq","xh","zmo","aug"], "groups": [1,1,0,1,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["exb","oq","lq","zmo"]

test_input = { "n": 7, "words": ["f","r","k","h","m","v","p"], "groups": [1,0,0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["f","r","m","v"]

test_input = { "n": 7, "words": ["fd","fc","jm","z","lg","kl","ux"], "groups": [0,1,0,1,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["fd","fc","jm","z","lg","kl","ux"]

test_input = { "n": 7, "words": ["ft","iw","m","v","gx","d","pm"], "groups": [1,1,1,0,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ft","v","gx"]

test_input = { "n": 7, "words": ["lma","i","rt","xar","bfx","np","x"], "groups": [1,1,1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["lma","np","x"]

test_input = { "n": 7, "words": ["nsv","r","o","qo","pb","xqv","clb"], "groups": [1,1,0,0,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["nsv","o"]

test_input = { "n": 7, "words": ["p","qdb","zcd","l","tv","ln","ogb"], "groups": [1,1,0,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["p","zcd","l","tv","ogb"]

test_input = { "n": 7, "words": ["z","cee","j","jqu","w","ljr","k"], "groups": [1,0,1,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["z","cee","j","w","k"]

test_input = { "n": 8, "words": ["h","p","q","t","j","a","c","n"], "groups": [0,1,1,1,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["h","p","j","c"]

test_input = { "n": 8, "words": ["r","v","c","t","d","a","x","o"], "groups": [1,1,0,1,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["r","c","t","a","o"]

test_input = { "n": 8, "words": ["u","l","a","y","j","s","h","q"], "groups": [0,0,0,0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["u","s","h"]

test_input = { "n": 8, "words": ["x","mr","yyf","l","z","q","zvj","zqt"], "groups": [0,1,1,1,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["x","mr","z","q","zqt"]

test_input = { "n": 8, "words": ["y","x","i","xtm","ze","n","cma","dgk"], "groups": [0,1,0,0,1,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","x","i","ze","cma"]

test_input = { "n": 8, "words": ["yun","x","zpp","bpr","ii","ezg","dn","k"], "groups": [0,1,1,1,1,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["yun","x","ezg","dn","k"]

test_input = { "n": 9, "words": ["ckr","iz","top","of","sb","wv","hb","da","wd"], "groups": [1,1,0,1,1,0,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ckr","top","of","wv","wd"]

test_input = { "n": 9, "words": ["g","h","u","n","w","o","f","p","m"], "groups": [1,0,0,1,1,0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["g","h","n","o","p","m"]

test_input = { "n": 9, "words": ["ilw","t","dyy","irz","oxy","k","rfj","hi","zxe"], "groups": [1,1,1,0,1,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ilw","irz","oxy","rfj","hi"]

test_input = { "n": 9, "words": ["l","iuz","d","tfw","mu","a","rp","mrb","wnl"], "groups": [1,1,1,1,1,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["l","a","rp","wnl"]

test_input = { "n": 9, "words": ["mc","b","yr","cj","zk","wi","esm","yu","cw"], "groups": [0,0,1,1,0,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["mc","yr","zk","esm","cw"]

test_input = { "n": 9, "words": ["nw","hx","ygc","vjo","jmv","p","juv","b","y"], "groups": [0,1,0,0,1,0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["nw","hx","ygc","jmv","p","b","y"]

test_input = { "n": 9, "words": ["osq","qiw","h","tc","xg","tvt","fqp","zq","b"], "groups": [0,0,1,0,1,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["osq","h","tc","xg","fqp","zq"]

test_input = { "n": 9, "words": ["vr","lw","e","g","dz","kf","qe","h","p"], "groups": [1,0,0,1,1,0,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["vr","lw","g","kf"]

test_input = { "n": 10, "words": ["gy","nd","l","hr","i","qf","zz","nq","e","oa"], "groups": [0,1,0,0,1,0,1,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["gy","nd","l","i","qf","zz","oa"]

test_input = { "n": 10, "words": ["j","r","h","t","z","b","a","s","v","q"], "groups": [1,0,1,1,1,1,0,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["j","r","h","a","q"]

test_input = { "n": 10, "words": ["k","f","u","h","x","w","c","e","l","p"], "groups": [0,1,1,1,1,1,1,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["k","f","p"]

test_input = { "n": 10, "words": ["lj","huy","lg","h","o","b","ava","ay","r","us"], "groups": [1,1,1,1,0,0,1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["lj","o","ava"]

test_input = { "n": 10, "words": ["m","d","xv","dp","nq","xi","e","g","n","qw"], "groups": [1,0,1,1,1,1,0,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["m","d","xv","e","g","n","qw"]

test_input = { "n": 10, "words": ["n","c","y","h","w","m","g","t","x","v"], "groups": [1,1,1,0,0,1,0,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n","h","m","g","v"]

test_input = { "n": 10, "words": ["o","w","l","g","m","x","f","q","c","v"], "groups": [1,1,1,0,1,1,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["o","g","m","q","v"]

test_input = { "n": 10, "words": ["p","mw","m","xld","j","jv","n","so","pkd","rwt"], "groups": [0,0,1,0,1,1,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["p","m","xld","j","n","pkd"]

test_input = { "n": 10, "words": ["vyv","msl","d","bu","ubl","bgk","sz","njv","pf","s"], "groups": [1,0,1,1,0,0,1,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["vyv","msl","d","ubl","sz","njv","pf","s"]

test_input = { "n": 10, "words": ["y","mz","lt","ur","o","m","djh","tb","w","j"], "groups": [0,0,1,0,1,1,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","lt","ur","o","djh","tb","w"]

test_input = { "n": 10, "words": ["y","s","i","v","a","w","l","q","k","t"], "groups": [0,1,1,1,0,1,1,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","s","a","w","k"]

test_input = { "n": 11, "words": ["a","tea","ldt","ybm","zkw","r","d","dms","le","u","ze"], "groups": [1,1,0,0,0,1,1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["a","ldt","r","u","ze"]

test_input = { "n": 11, "words": ["c","o","e","r","x","w","b","d","h","y","z"], "groups": [1,0,1,0,1,0,1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c","o","e","r","x","w","b","y","z"]

test_input = { "n": 11, "words": ["chu","a","qdx","fgd","qe","bqc","x","kbx","sv","ly","br"], "groups": [1,0,0,0,0,0,1,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["chu","a","x","kbx","sv","br"]

test_input = { "n": 11, "words": ["ec","jdf","b","wa","kjd","bb","ty","yi","ybw","ilj","cv"], "groups": [0,1,0,1,1,1,1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ec","jdf","b","wa","ilj","cv"]

test_input = { "n": 11, "words": ["ew","isn","fl","mg","pdg","d","p","hh","e","y","whm"], "groups": [0,0,1,1,0,0,0,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ew","fl","pdg","y"]

test_input = { "n": 11, "words": ["h","o","d","y","r","c","p","b","g","j","k"], "groups": [1,1,0,1,1,0,1,1,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["h","d","y","c","p","g"]

test_input = { "n": 11, "words": ["ipr","l","zy","j","h","hdt","m","d","pd","nv","wy"], "groups": [1,1,1,1,0,1,0,1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ipr","h","hdt","m","d"]

test_input = { "n": 11, "words": ["j","g","go","a","f","bg","o","l","ze","kq","w"], "groups": [0,0,1,0,1,0,0,0,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["j","go","a","f","bg","ze","kq","w"]

test_input = { "n": 11, "words": ["j","r","a","g","x","b","y","v","k","i","c"], "groups": [0,1,0,0,0,0,1,1,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["j","r","a","y","k"]

test_input = { "n": 11, "words": ["kgo","han","nlu","tv","us","pk","xw","cxc","eml","v","msz"], "groups": [1,0,0,1,0,0,1,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["kgo","han","tv","us","xw","cxc","eml","msz"]

test_input = { "n": 11, "words": ["kh","op","ij","te","hk","pmt","v","ne","en","b","zuj"], "groups": [0,0,1,1,1,0,1,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["kh","ij","pmt","v","en","b"]

test_input = { "n": 11, "words": ["ms","t","oz","x","pw","ik","d","gj","z","ps","i"], "groups": [1,1,0,1,0,0,1,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ms","oz","x","pw","d","z","i"]