longest-unequal-adjacent-groups-subsequence-ii

Longest Unequal Adjacent Groups Subsequence II

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

The hamming distance between two strings of equal length is the number of positions at which the corresponding characters are different.

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, the following holds:

 * For adjacent indices in the subsequence, their corresponding groups are unequal, i.e., groups[ij] != groups[ij + 1], for each j where 0 < j + 1 < k.
 * words[ij] and words[ij + 1] are equal in length, and the hamming distance between them is 1, where 0 < j + 1 < k, for all indices in the subsequence.

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 = ["bab","dab","cab"], groups = [1,2,2]
Output: ["bab","cab"]
Explanation: A subsequence that can be selected is [0,2].
- groups[0] != groups[2]
- words[0].length == words[2].length, and the hamming distance between them is 1.
So, a valid answer is [words[0],words[2]] = ["bab","cab"].
Another subsequence that can be selected is [0,1].
- groups[0] != groups[1]
- words[0].length == words[1].length, and the hamming distance between them is 1.
So, another valid answer is [words[0],words[1]] = ["bab","dab"].
It can be shown that the length of the longest subsequence of indices that satisfies the conditions is 2.

Example 2:

Input: n = 4, words = ["a","b","c","d"], groups = [1,2,3,4]
Output: ["a","b","c","d"]
Explanation: We can select the subsequence [0,1,2,3].
It satisfies both conditions.
Hence, the answer is [words[0],words[1],words[2],words[3]] = ["a","b","c","d"].
It has the longest length among all subsequences of indices that satisfy the conditions.
Hence, it is the only answer.

Constraints:

 * 1 <= n == words.length == groups.length <= 1000
 * 1 <= words[i].length <= 10
 * 1 <= groups[i] <= n
 * 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 array groups, both arrays having length n.

The hamming distance between two strings of equal length is the number of positions at which the corresponding characters are different.

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, the following holds:

 * For adjacent indices in the subsequence, their corresponding groups are unequal, i.e., groups[ij] != groups[ij + 1], for each j where 0 < j + 1 < k.
 * words[ij] and words[ij + 1] are equal in length, and the hamming distance between them is 1, where 0 < j + 1 < k, for all indices in the subsequence.

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 = ["bab","dab","cab"], groups = [1,2,2]
Output: ["bab","cab"]
Explanation: A subsequence that can be selected is [0,2].
- groups[0] != groups[2]
- words[0].length == words[2].length, and the hamming distance between them is 1.
So, a valid answer is [words[0],words[2]] = ["bab","cab"].
Another subsequence that can be selected is [0,1].
- groups[0] != groups[1]
- words[0].length == words[1].length, and the hamming distance between them is 1.
So, another valid answer is [words[0],words[1]] = ["bab","dab"].
It can be shown that the length of the longest subsequence of indices that satisfies the conditions is 2.

Example 2:

Input: n = 4, words = ["a","b","c","d"], groups = [1,2,3,4]
Output: ["a","b","c","d"]
Explanation: We can select the subsequence [0,1,2,3].
It satisfies both conditions.
Hence, the answer is [words[0],words[1],words[2],words[3]] = ["a","b","c","d"].
It has the longest length among all subsequences of indices that satisfy the conditions.
Hence, it is the only answer.

Constraints:

 * 1 <= n == words.length == groups.length <= 1000
 * 1 <= words[i].length <= 10
 * 1 <= groups[i] <= n
 * 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": ["bab","dab","cab"], "groups": [1,2,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["bab","cab"]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "n": 3, "words": ["aab","ca","cbd"], "groups": [3,3,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cbd"]

test_input = { "n": 3, "words": ["aeb","bc","abdb"], "groups": [2,3,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["abdb"]

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

test_input = { "n": 3, "words": ["cc","aa","dda"], "groups": [2,2,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dda"]

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

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

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

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

test_input = { "n": 3, "words": ["db","ccce","edbac"], "groups": [3,2,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["edbac"]

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

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

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

test_input = { "n": 3, "words": ["dd","bb","aac"], "groups": [3,3,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["aac"]

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

test_input = { "n": 3, "words": ["eee","abecab","dc"], "groups": [2,2,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dc"]

test_input = { "n": 4, "words": ["ac","caa","cda","ba"], "groups": [3,1,2,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["caa","cda"]

test_input = { "n": 4, "words": ["bab","bac","dbd","dd"], "groups": [1,1,3,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dd"]

test_input = { "n": 4, "words": ["bab","bdd","bca","dab"], "groups": [2,4,1,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dab"]

test_input = { "n": 4, "words": ["bbbd","babca","ebddde","cce"], "groups": [3,4,3,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cce"]

test_input = { "n": 4, "words": ["beb","eacedc","aeeb","cdd"], "groups": [1,4,3,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cdd"]

test_input = { "n": 4, "words": ["cac","aaa","dd","cda"], "groups": [1,4,2,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cda"]

test_input = { "n": 4, "words": ["cbb","db","bdd","bd"], "groups": [2,3,4,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["bd"]

test_input = { "n": 4, "words": ["cdc","dc","bd","aca"], "groups": [3,2,2,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["aca"]

test_input = { "n": 4, "words": ["ceacd","ac","bebdae","dbbbcb"], "groups": [2,3,1,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dbbbcb"]

test_input = { "n": 4, "words": ["dcaacc","da","ddcbd","dd"], "groups": [2,3,1,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["da","dd"]

test_input = { "n": 4, "words": ["deeb","edbea","ad","ecedd"], "groups": [1,1,1,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ecedd"]

test_input = { "n": 4, "words": ["ebe","bcca","caabaa","abb"], "groups": [1,4,4,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["abb"]

test_input = { "n": 5, "words": ["abd","bab","bc","ac","acd"], "groups": [3,5,3,3,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["abd","acd"]

test_input = { "n": 5, "words": ["acc","ab","baa","dac","aa"], "groups": [3,1,2,3,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ab","aa"]

test_input = { "n": 5, "words": ["acda","caae","ccad","ac","ddeedb"], "groups": [4,2,4,1,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ddeedb"]

test_input = { "n": 5, "words": ["ade","ea","aabd","bc","aaaabe"], "groups": [4,2,4,4,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["aaaabe"]

test_input = { "n": 5, "words": ["ba","ee","ed","ddddd","ce"], "groups": [4,4,4,5,5] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ee","ce"]

test_input = { "n": 5, "words": ["bacd","adbbab","ba","ec","deecbe"], "groups": [4,4,5,5,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["deecbe"]

test_input = { "n": 5, "words": ["bad","cab","abb","cd","ba"], "groups": [2,5,3,4,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ba"]

test_input = { "n": 5, "words": ["ca","cb","bcd","bb","ddc"], "groups": [2,4,2,5,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ca","cb","bb"]

test_input = { "n": 5, "words": ["ccb","ac","aa","bad","ab"], "groups": [3,5,2,2,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ac","aa","ab"]

test_input = { "n": 5, "words": ["cd","dd","ad","aaa","db"], "groups": [2,3,3,5,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cd","dd","db"]

test_input = { "n": 5, "words": ["cda","ab","cb","ccb","baa"], "groups": [3,1,2,1,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ab","cb"]

test_input = { "n": 5, "words": ["dc","eca","cdade","aaaccd","deb"], "groups": [3,2,3,1,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["deb"]

test_input = { "n": 5, "words": ["dceba","dbcab","bacd","bacdab","bdeca"], "groups": [4,3,5,3,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["bdeca"]

test_input = { "n": 5, "words": ["deeb","ee","bbbbe","bddba","cdb"], "groups": [4,4,1,3,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cdb"]

test_input = { "n": 6, "words": ["aab","cab","ba","dba","daa","bca"], "groups": [4,3,4,6,4,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dba","daa"]

test_input = { "n": 6, "words": ["aca","dd","aab","dac","adb","bad"], "groups": [2,6,2,1,4,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["aab","adb"]

test_input = { "n": 6, "words": ["ad","bb","cc","bc","bcb","abc"], "groups": [3,5,5,5,1,5] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["abc"]

test_input = { "n": 6, "words": ["bcb","cba","cab","cca","ad","cd"], "groups": [6,5,1,5,5,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ad","cd"]

test_input = { "n": 6, "words": ["bdaaee","cb","ecaad","accdd","ba","adad"], "groups": [2,4,4,6,1,5] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["adad"]

test_input = { "n": 6, "words": ["bdccb","cece","dbdda","bbc","bcbae","badc"], "groups": [4,2,4,1,1,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["badc"]

test_input = { "n": 6, "words": ["cba","cc","cd","ccc","aba","ac"], "groups": [3,6,2,4,2,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cba","aba"]

test_input = { "n": 6, "words": ["ccd","db","cbb","cb","cab","acd"], "groups": [5,1,5,5,6,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ccd","acd"]

test_input = { "n": 6, "words": ["eb","eaab","accdba","ecba","aec","dacacd"], "groups": [4,6,1,6,2,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dacacd"]

test_input = { "n": 6, "words": ["ee","aab","db","cc","dead","aee"], "groups": [5,5,4,2,5,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["aee"]

test_input = { "n": 7, "words": ["aad","cba","bda","dc","aba","dbc","ac"], "groups": [6,4,1,7,5,2,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dc","ac"]

test_input = { "n": 7, "words": ["adcaa","db","dced","ded","eeadce","bdbbe","acaadc"], "groups": [7,5,4,2,1,5,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["acaadc"]

test_input = { "n": 7, "words": ["bcabd","cd","cbaadc","cda","bcde","ccedca","ba"], "groups": [7,3,6,7,1,7,5] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ba"]

test_input = { "n": 7, "words": ["bd","dbd","dcc","cb","ac","abd","bb"], "groups": [1,3,3,6,6,4,5] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cb","bb"]

test_input = { "n": 7, "words": ["cbde","aad","dbdceb","ae","eca","bd","bba"], "groups": [7,5,7,6,4,5,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["bba"]

test_input = { "n": 7, "words": ["cdcdad","baaee","cba","ceae","ab","bedbab","eb"], "groups": [5,3,7,1,7,6,7] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["eb"]

test_input = { "n": 7, "words": ["dabbdb","eacbdb","bbdea","cdcaa","eaeeb","cebabe","ad"], "groups": [3,5,5,6,3,4,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ad"]

test_input = { "n": 7, "words": ["dbcca","dcdd","bebbc","cbed","cb","abed","ac"], "groups": [4,6,6,6,3,7,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cbed","abed"]

test_input = { "n": 7, "words": ["dcc","cba","ab","cb","aac","aba","db"], "groups": [3,2,1,6,2,6,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ab","db"]

test_input = { "n": 7, "words": ["ddd","cd","adb","bcc","da","ab","ad"], "groups": [2,3,6,7,3,7,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ab","ad"]

test_input = { "n": 7, "words": ["edded","ab","bc","aeac","ec","db","be"], "groups": [3,2,3,6,3,4,3] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ab","db"]

test_input = { "n": 8, "words": ["addb","beeddc","dcdce","ddaeed","ddbbb","aeea","adee","dbcbdc"], "groups": [1,5,7,1,5,7,7,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dbcbdc"]

test_input = { "n": 8, "words": ["ba","cca","dcb","cd","aa","bd","cda","bcb"], "groups": [6,1,2,2,3,7,7,7] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dcb","bcb"]

test_input = { "n": 8, "words": ["baa","cb","aab","ddc","bba","cdb","abb","dc"], "groups": [1,8,1,1,8,6,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["baa","bba"]

test_input = { "n": 8, "words": ["bbde","edea","dcd","eebbed","ddab","ae","ec","ade"], "groups": [7,3,2,4,7,3,6,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ade"]

test_input = { "n": 8, "words": ["bc","aa","cb","dd","aaa","ccb","da","bbb"], "groups": [5,4,6,8,6,7,7,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dd","da"]

test_input = { "n": 8, "words": ["bcc","aac","ac","dd","bdd","ada","bbb","db"], "groups": [7,7,1,7,1,1,6,7] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["db"]

test_input = { "n": 8, "words": ["cb","dcc","da","cbb","bd","dbc","ab","db"], "groups": [4,5,5,7,8,1,3,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cb","ab","db"]

test_input = { "n": 8, "words": ["cbaeeb","decd","dbc","cbdcca","acbcbe","adccc","eb","ecbbea"], "groups": [6,7,8,6,3,5,1,7] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ecbbea"]

test_input = { "n": 8, "words": ["cc","aa","cab","dbc","bbb","adc","cba","cca"], "groups": [6,1,6,6,4,8,1,5] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cba","cca"]

test_input = { "n": 8, "words": ["cc","dcd","dac","dc","ac","ad","bbb","cbb"], "groups": [7,7,2,5,4,1,6,2] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cc","dc","ac","ad"]

test_input = { "n": 8, "words": ["ccdbdc","dcce","ebedde","ceb","edee","ca","ad","dddee"], "groups": [6,6,3,4,7,1,5,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["dddee"]

test_input = { "n": 8, "words": ["cd","bd","ada","ba","ac","bac","aad","ccb"], "groups": [3,4,8,7,6,7,2,4] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cd","bd","ba"]

test_input = { "n": 8, "words": ["da","bd","ccd","dd","ab","cc","aab","ac"], "groups": [6,5,4,8,8,2,2,6] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cc","ac"]

test_input = { "n": 8, "words": ["dab","ecedc","badca","cedacb","bdeab","bccedc","bebc","aeade"], "groups": [3,7,6,8,6,6,7,5] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["aeade"]


count-of-sub-multisets-with-bounded-sum

Count of Sub-Multisets With Bounded Sum

Prompt:
"""
You are given a 0-indexed array nums of non-negative integers, and two integers l and r.

Return the count of sub-multisets within nums where the sum of elements in each subset falls within the inclusive range of [l, r].

Since the answer may be large, return it modulo 109 + 7.

A sub-multiset is an unordered collection of elements of the array in which a given value x can occur 0, 1, ..., occ[x] times, where occ[x] is the number of occurrences of x in the array.

Note that:

 * Two sub-multisets are the same if sorting both sub-multisets results in identical multisets.
 * The sum of an empty multiset is 0.

Example 1:

Input: nums = [1,2,2,3], l = 6, r = 6
Output: 1
Explanation: The only subset of nums that has a sum of 6 is {1, 2, 3}.

Example 2:

Input: nums = [2,1,4,2,7], l = 1, r = 5
Output: 7
Explanation: The subsets of nums that have a sum within the range [1, 5] are {1}, {2}, {4}, {2, 2}, {1, 2}, {1, 4}, and {1, 2, 2}.

Example 3:

Input: nums = [1,2,1,3,5,2], l = 3, r = 5
Output: 9
Explanation: The subsets of nums that have a sum within the range [3, 5] are {3}, {5}, {1, 2}, {1, 3}, {2, 2}, {2, 3}, {1, 1, 2}, {1, 1, 3}, and {1, 2, 2}.

Constraints:

 * 1 <= nums.length <= 2 * 104
 * 0 <= nums[i] <= 2 * 104
 * Sum of nums does not exceed 2 * 104.
 * 0 <= l <= r <= 2 * 104
"""
class Solution:
    def countSubMultisets(self, nums: List[int], l: int, r: int) -> int:

You are given a 0-indexed array nums of non-negative integers, and two integers l and r.

Return the count of sub-multisets within nums where the sum of elements in each subset falls within the inclusive range of [l, r].

Since the answer may be large, return it modulo 109 + 7.

A sub-multiset is an unordered collection of elements of the array in which a given value x can occur 0, 1, ..., occ[x] times, where occ[x] is the number of occurrences of x in the array.

Note that:

 * Two sub-multisets are the same if sorting both sub-multisets results in identical multisets.
 * The sum of an empty multiset is 0.

Example 1:

Input: nums = [1,2,2,3], l = 6, r = 6
Output: 1
Explanation: The only subset of nums that has a sum of 6 is {1, 2, 3}.

Example 2:

Input: nums = [2,1,4,2,7], l = 1, r = 5
Output: 7
Explanation: The subsets of nums that have a sum within the range [1, 5] are {1}, {2}, {4}, {2, 2}, {1, 2}, {1, 4}, and {1, 2, 2}.

Example 3:

Input: nums = [1,2,1,3,5,2], l = 3, r = 5
Output: 9
Explanation: The subsets of nums that have a sum within the range [3, 5] are {3}, {5}, {1, 2}, {1, 3}, {2, 2}, {2, 3}, {1, 1, 2}, {1, 1, 3}, and {1, 2, 2}.

Constraints:

 * 1 <= nums.length <= 2 * 104
 * 0 <= nums[i] <= 2 * 104
 * Sum of nums does not exceed 2 * 104.
 * 0 <= l <= r <= 2 * 104

Please complete the code below to solve above prblem:
```python
class Solution:
    def countSubMultisets(self, nums: List[int], l: int, r: int) -> int:

```

my_solution = Solution()

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

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

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

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

test_input = { "nums": [0,0,0,0,0], "l": 0, "r": 0 }
assert my_solution.countSubMultisets(**test_input) == 6

test_input = { "nums": [0,0,0,1,2,5,2,3], "l": 0, "r": 3 }
assert my_solution.countSubMultisets(**test_input) == 20

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

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

test_input = { "nums": [1,1,2], "l": 2, "r": 4 }
assert my_solution.countSubMultisets(**test_input) == 4

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

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

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

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

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

test_input = { "nums": [2,2,2], "l": 3, "r": 6 }
assert my_solution.countSubMultisets(**test_input) == 2

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

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

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

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

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

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

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

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

test_input = { "nums": [1,1,3,3], "l": 8, "r": 8 }
assert my_solution.countSubMultisets(**test_input) == 1

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

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

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

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

test_input = { "nums": [1,2,2,2], "l": 1, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 7

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

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

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

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

test_input = { "nums": [1,3,1,1], "l": 6, "r": 6 }
assert my_solution.countSubMultisets(**test_input) == 1

test_input = { "nums": [1,3,1,2], "l": 7, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 1

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

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

test_input = { "nums": [1,3,2,2], "l": 7, "r": 8 }
assert my_solution.countSubMultisets(**test_input) == 2

test_input = { "nums": [1,3,2,3], "l": 1, "r": 9 }
assert my_solution.countSubMultisets(**test_input) == 11

test_input = { "nums": [1,3,3,1], "l": 7, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 1

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

test_input = { "nums": [1,3,3,3], "l": 9, "r": 10 }
assert my_solution.countSubMultisets(**test_input) == 2

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

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

test_input = { "nums": [2,1,1,3], "l": 7, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 1

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

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

test_input = { "nums": [2,1,2,3], "l": 7, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 1

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

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

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

test_input = { "nums": [2,2,1,1], "l": 6, "r": 6 }
assert my_solution.countSubMultisets(**test_input) == 1

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

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

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

test_input = { "nums": [2,2,2,2], "l": 3, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 2

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

test_input = { "nums": [2,2,3,1], "l": 7, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 1

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [3,1,1,2], "l": 7, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 1

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

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

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

test_input = { "nums": [3,1,2,3], "l": 5, "r": 9 }
assert my_solution.countSubMultisets(**test_input) == 6

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

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

test_input = { "nums": [3,1,3,3], "l": 9, "r": 10 }
assert my_solution.countSubMultisets(**test_input) == 2

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

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

test_input = { "nums": [3,2,1,3], "l": 5, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 4

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

test_input = { "nums": [3,2,2,2], "l": 6, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 2

test_input = { "nums": [3,2,2,3], "l": 2, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 6

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

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

test_input = { "nums": [3,2,3,3], "l": 1, "r": 11 }
assert my_solution.countSubMultisets(**test_input) == 7

test_input = { "nums": [3,3,1,1], "l": 8, "r": 8 }
assert my_solution.countSubMultisets(**test_input) == 1

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

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

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

test_input = { "nums": [3,3,2,2], "l": 7, "r": 10 }
assert my_solution.countSubMultisets(**test_input) == 3

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

test_input = { "nums": [3,3,3,1], "l": 6, "r": 9 }
assert my_solution.countSubMultisets(**test_input) == 3

test_input = { "nums": [3,3,3,2], "l": 11, "r": 11 }
assert my_solution.countSubMultisets(**test_input) == 1

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

test_input = { "nums": [1,1,1,1,1], "l": 3, "r": 5 }
assert my_solution.countSubMultisets(**test_input) == 3

test_input = { "nums": [1,1,1,1,2], "l": 2, "r": 5 }
assert my_solution.countSubMultisets(**test_input) == 7

test_input = { "nums": [1,1,1,1,3], "l": 6, "r": 7 }
assert my_solution.countSubMultisets(**test_input) == 2

test_input = { "nums": [1,1,1,1,4], "l": 8, "r": 8 }
assert my_solution.countSubMultisets(**test_input) == 1


divisible-and-non-divisible-sums-difference

Divisible and Non-divisible Sums Difference

Prompt:
"""
You are given positive integers n and m.

Define two integers, num1 and num2, as follows:

 * num1: The sum of all integers in the range [1, n] that are not divisible by m.
 * num2: The sum of all integers in the range [1, n] that are divisible by m.

Return the integer num1 - num2.

Example 1:

Input: n = 10, m = 3
Output: 19
Explanation: In the given example:
- Integers in the range [1, 10] that are not divisible by 3 are [1,2,4,5,7,8,10], num1 is the sum of those integers = 37.
- Integers in the range [1, 10] that are divisible by 3 are [3,6,9], num2 is the sum of those integers = 18.
We return 37 - 18 = 19 as the answer.

Example 2:

Input: n = 5, m = 6
Output: 15
Explanation: In the given example:
- Integers in the range [1, 5] that are not divisible by 6 are [1,2,3,4,5], num1 is the sum of those integers = 15.
- Integers in the range [1, 5] that are divisible by 6 are [], num2 is the sum of those integers = 0.
We return 15 - 0 = 15 as the answer.

Example 3:

Input: n = 5, m = 1
Output: -15
Explanation: In the given example:
- Integers in the range [1, 5] that are not divisible by 1 are [], num1 is the sum of those integers = 0.
- Integers in the range [1, 5] that are divisible by 1 are [1,2,3,4,5], num2 is the sum of those integers = 15.
We return 0 - 15 = -15 as the answer.

Constraints:

 * 1 <= n, m <= 1000
"""
class Solution:
    def differenceOfSums(self, n: int, m: int) -> int:

You are given positive integers n and m.

Define two integers, num1 and num2, as follows:

 * num1: The sum of all integers in the range [1, n] that are not divisible by m.
 * num2: The sum of all integers in the range [1, n] that are divisible by m.

Return the integer num1 - num2.

Example 1:

Input: n = 10, m = 3
Output: 19
Explanation: In the given example:
- Integers in the range [1, 10] that are not divisible by 3 are [1,2,4,5,7,8,10], num1 is the sum of those integers = 37.
- Integers in the range [1, 10] that are divisible by 3 are [3,6,9], num2 is the sum of those integers = 18.
We return 37 - 18 = 19 as the answer.

Example 2:

Input: n = 5, m = 6
Output: 15
Explanation: In the given example:
- Integers in the range [1, 5] that are not divisible by 6 are [1,2,3,4,5], num1 is the sum of those integers = 15.
- Integers in the range [1, 5] that are divisible by 6 are [], num2 is the sum of those integers = 0.
We return 15 - 0 = 15 as the answer.

Example 3:

Input: n = 5, m = 1
Output: -15
Explanation: In the given example:
- Integers in the range [1, 5] that are not divisible by 1 are [], num1 is the sum of those integers = 0.
- Integers in the range [1, 5] that are divisible by 1 are [1,2,3,4,5], num2 is the sum of those integers = 15.
We return 0 - 15 = -15 as the answer.

Constraints:

 * 1 <= n, m <= 1000

Please complete the code below to solve above prblem:
```python
class Solution:
    def differenceOfSums(self, n: int, m: int) -> int:

```

my_solution = Solution()

test_input = { "n": 10, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 19

test_input = { "n": 5, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 15

test_input = { "n": 5, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -15

test_input = { "n": 15, "m": 9 }
assert my_solution.differenceOfSums(**test_input) == 102

test_input = { "n": 8, "m": 10 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 23, "m": 36 }
assert my_solution.differenceOfSums(**test_input) == 276

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

test_input = { "n": 36, "m": 7 }
assert my_solution.differenceOfSums(**test_input) == 456

test_input = { "n": 3, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 4, "m": 2 }
assert my_solution.differenceOfSums(**test_input) == -2

test_input = { "n": 9, "m": 7 }
assert my_solution.differenceOfSums(**test_input) == 31

test_input = { "n": 20, "m": 9 }
assert my_solution.differenceOfSums(**test_input) == 156

test_input = { "n": 3, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 6, "m": 16 }
assert my_solution.differenceOfSums(**test_input) == 21

test_input = { "n": 6, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -21

test_input = { "n": 5, "m": 25 }
assert my_solution.differenceOfSums(**test_input) == 15

test_input = { "n": 9, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 9

test_input = { "n": 8, "m": 23 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 17, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -153

test_input = { "n": 18, "m": 9 }
assert my_solution.differenceOfSums(**test_input) == 117

test_input = { "n": 22, "m": 30 }
assert my_solution.differenceOfSums(**test_input) == 253

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

test_input = { "n": 33, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 523

test_input = { "n": 7, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 28

test_input = { "n": 12, "m": 24 }
assert my_solution.differenceOfSums(**test_input) == 78

test_input = { "n": 26, "m": 25 }
assert my_solution.differenceOfSums(**test_input) == 301

test_input = { "n": 9, "m": 16 }
assert my_solution.differenceOfSums(**test_input) == 45

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

test_input = { "n": 29, "m": 42 }
assert my_solution.differenceOfSums(**test_input) == 435

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

test_input = { "n": 36, "m": 10 }
assert my_solution.differenceOfSums(**test_input) == 546

test_input = { "n": 45, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 507

test_input = { "n": 3, "m": 7 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 6, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 21

test_input = { "n": 3, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 8, "m": 28 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 18, "m": 23 }
assert my_solution.differenceOfSums(**test_input) == 171

test_input = { "n": 11, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 54

test_input = { "n": 35, "m": 10 }
assert my_solution.differenceOfSums(**test_input) == 510

test_input = { "n": 29, "m": 18 }
assert my_solution.differenceOfSums(**test_input) == 399

test_input = { "n": 1, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -1

test_input = { "n": 12, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 62

test_input = { "n": 7, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 28

test_input = { "n": 17, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 63

test_input = { "n": 16, "m": 15 }
assert my_solution.differenceOfSums(**test_input) == 106

test_input = { "n": 18, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 45

test_input = { "n": 4, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 10

test_input = { "n": 3, "m": 21 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 15, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 72

test_input = { "n": 9, "m": 39 }
assert my_solution.differenceOfSums(**test_input) == 45

test_input = { "n": 19, "m": 18 }
assert my_solution.differenceOfSums(**test_input) == 154

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

test_input = { "n": 41, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -861

test_input = { "n": 3, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -6

test_input = { "n": 16, "m": 13 }
assert my_solution.differenceOfSums(**test_input) == 110

test_input = { "n": 32, "m": 10 }
assert my_solution.differenceOfSums(**test_input) == 408

test_input = { "n": 41, "m": 34 }
assert my_solution.differenceOfSums(**test_input) == 793

test_input = { "n": 33, "m": 40 }
assert my_solution.differenceOfSums(**test_input) == 561

test_input = { "n": 36, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 506

test_input = { "n": 8, "m": 34 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 40, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 676

test_input = { "n": 28, "m": 9 }
assert my_solution.differenceOfSums(**test_input) == 298

test_input = { "n": 20, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 138

test_input = { "n": 13, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 55

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

test_input = { "n": 14, "m": 17 }
assert my_solution.differenceOfSums(**test_input) == 105

test_input = { "n": 35, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 342

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

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

test_input = { "n": 7, "m": 7 }
assert my_solution.differenceOfSums(**test_input) == 14

test_input = { "n": 12, "m": 26 }
assert my_solution.differenceOfSums(**test_input) == 78

test_input = { "n": 14, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -105

test_input = { "n": 2, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -3

test_input = { "n": 20, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 84

test_input = { "n": 8, "m": 27 }
assert my_solution.differenceOfSums(**test_input) == 36

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

test_input = { "n": 13, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 91

test_input = { "n": 7, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -28

test_input = { "n": 31, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 272

test_input = { "n": 11, "m": 25 }
assert my_solution.differenceOfSums(**test_input) == 66

test_input = { "n": 5, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 15

test_input = { "n": 33, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 489

test_input = { "n": 4, "m": 26 }
assert my_solution.differenceOfSums(**test_input) == 10

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

test_input = { "n": 13, "m": 20 }
assert my_solution.differenceOfSums(**test_input) == 91

test_input = { "n": 6, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 21

test_input = { "n": 8, "m": 26 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 4, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -10

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

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

test_input = { "n": 4, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 2

test_input = { "n": 8, "m": 2 }
assert my_solution.differenceOfSums(**test_input) == -4

test_input = { "n": 15, "m": 21 }
assert my_solution.differenceOfSums(**test_input) == 120

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

test_input = { "n": 12, "m": 2 }
assert my_solution.differenceOfSums(**test_input) == -6

test_input = { "n": 40, "m": 14 }
assert my_solution.differenceOfSums(**test_input) == 736

test_input = { "n": 14, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 105

test_input = { "n": 18, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -171

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

test_input = { "n": 31, "m": 18 }
assert my_solution.differenceOfSums(**test_input) == 460


minimum-processing-time

Minimum Processing Time

Prompt:
"""
You have n processors each having 4 cores and n * 4 tasks that need to be executed such that each core should perform only one task.

Given a 0-indexed integer array processorTime representing the time at which each processor becomes available for the first time and a 0-indexed integer array tasks representing the time it takes to execute each task, return the minimum time when all of the tasks have been executed by the processors.

Note: Each core executes the task independently of the others.

Example 1:

Input: processorTime = [8,10], tasks = [2,2,3,1,8,7,4,5]
Output: 16
Explanation:
It's optimal to assign the tasks at indexes 4, 5, 6, 7 to the first processor which becomes available at time = 8, and the tasks at indexes 0, 1, 2, 3 to the second processor which becomes available at time = 10.
Time taken by the first processor to finish execution of all tasks = max(8 + 8, 8 + 7, 8 + 4, 8 + 5) = 16.
Time taken by the second processor to finish execution of all tasks = max(10 + 2, 10 + 2, 10 + 3, 10 + 1) = 13.
Hence, it can be shown that the minimum time taken to execute all the tasks is 16.

Example 2:

Input: processorTime = [10,20], tasks = [2,3,1,2,5,8,4,3]
Output: 23
Explanation:
It's optimal to assign the tasks at indexes 1, 4, 5, 6 to the first processor which becomes available at time = 10, and the tasks at indexes 0, 2, 3, 7 to the second processor which becomes available at time = 20.
Time taken by the first processor to finish execution of all tasks = max(10 + 3, 10 + 5, 10 + 8, 10 + 4) = 18.
Time taken by the second processor to finish execution of all tasks = max(20 + 2, 20 + 1, 20 + 2, 20 + 3) = 23.
Hence, it can be shown that the minimum time taken to execute all the tasks is 23.

Constraints:

 * 1 <= n == processorTime.length <= 25000
 * 1 <= tasks.length <= 105
 * 0 <= processorTime[i] <= 109
 * 1 <= tasks[i] <= 109
 * tasks.length == 4 * n
"""
class Solution:
    def minProcessingTime(self, processorTime: List[int], tasks: List[int]) -> int:

You have n processors each having 4 cores and n * 4 tasks that need to be executed such that each core should perform only one task.

Given a 0-indexed integer array processorTime representing the time at which each processor becomes available for the first time and a 0-indexed integer array tasks representing the time it takes to execute each task, return the minimum time when all of the tasks have been executed by the processors.

Note: Each core executes the task independently of the others.

Example 1:

Input: processorTime = [8,10], tasks = [2,2,3,1,8,7,4,5]
Output: 16
Explanation:
It's optimal to assign the tasks at indexes 4, 5, 6, 7 to the first processor which becomes available at time = 8, and the tasks at indexes 0, 1, 2, 3 to the second processor which becomes available at time = 10.
Time taken by the first processor to finish execution of all tasks = max(8 + 8, 8 + 7, 8 + 4, 8 + 5) = 16.
Time taken by the second processor to finish execution of all tasks = max(10 + 2, 10 + 2, 10 + 3, 10 + 1) = 13.
Hence, it can be shown that the minimum time taken to execute all the tasks is 16.

Example 2:

Input: processorTime = [10,20], tasks = [2,3,1,2,5,8,4,3]
Output: 23
Explanation:
It's optimal to assign the tasks at indexes 1, 4, 5, 6 to the first processor which becomes available at time = 10, and the tasks at indexes 0, 2, 3, 7 to the second processor which becomes available at time = 20.
Time taken by the first processor to finish execution of all tasks = max(10 + 3, 10 + 5, 10 + 8, 10 + 4) = 18.
Time taken by the second processor to finish execution of all tasks = max(20 + 2, 20 + 1, 20 + 2, 20 + 3) = 23.
Hence, it can be shown that the minimum time taken to execute all the tasks is 23.

Constraints:

 * 1 <= n == processorTime.length <= 25000
 * 1 <= tasks.length <= 105
 * 0 <= processorTime[i] <= 109
 * 1 <= tasks[i] <= 109
 * tasks.length == 4 * n

Please complete the code below to solve above prblem:
```python
class Solution:
    def minProcessingTime(self, processorTime: List[int], tasks: List[int]) -> int:

```


apply-operations-to-make-two-strings-equal

Apply Operations to Make Two Strings Equal

Prompt:
"""
You are given two 0-indexed binary strings s1 and s2, both of length n, and a positive integer x.

You can perform any of the following operations on the string s1 any number of times:

 * Choose two indices i and j, and flip both s1[i] and s1[j]. The cost of this operation is x.
 * Choose an index i such that i < n - 1 and flip both s1[i] and s1[i + 1]. The cost of this operation is 1.

Return the minimum cost needed to make the strings s1 and s2 equal, or return -1 if it is impossible.

Note that flipping a character means changing it from 0 to 1 or vice-versa.

Example 1:

Input: s1 = "1100011000", s2 = "0101001010", x = 2
Output: 4
Explanation: We can do the following operations:
- Choose i = 3 and apply the second operation. The resulting string is s1 = "1101111000".
- Choose i = 4 and apply the second operation. The resulting string is s1 = "1101001000".
- Choose i = 0 and j = 8 and apply the first operation. The resulting string is s1 = "0101001010" = s2.
The total cost is 1 + 1 + 2 = 4. It can be shown that it is the minimum cost possible.

Example 2:

Input: s1 = "10110", s2 = "00011", x = 4
Output: -1
Explanation: It is not possible to make the two strings equal.

Constraints:

 * n == s1.length == s2.length
 * 1 <= n, x <= 500
 * s1 and s2 consist only of the characters '0' and '1'.
"""
class Solution:
    def minOperations(self, s1: str, s2: str, x: int) -> int:

You are given two 0-indexed binary strings s1 and s2, both of length n, and a positive integer x.

You can perform any of the following operations on the string s1 any number of times:

 * Choose two indices i and j, and flip both s1[i] and s1[j]. The cost of this operation is x.
 * Choose an index i such that i < n - 1 and flip both s1[i] and s1[i + 1]. The cost of this operation is 1.

Return the minimum cost needed to make the strings s1 and s2 equal, or return -1 if it is impossible.

Note that flipping a character means changing it from 0 to 1 or vice-versa.

Example 1:

Input: s1 = "1100011000", s2 = "0101001010", x = 2
Output: 4
Explanation: We can do the following operations:
- Choose i = 3 and apply the second operation. The resulting string is s1 = "1101111000".
- Choose i = 4 and apply the second operation. The resulting string is s1 = "1101001000".
- Choose i = 0 and j = 8 and apply the first operation. The resulting string is s1 = "0101001010" = s2.
The total cost is 1 + 1 + 2 = 4. It can be shown that it is the minimum cost possible.

Example 2:

Input: s1 = "10110", s2 = "00011", x = 4
Output: -1
Explanation: It is not possible to make the two strings equal.

Constraints:

 * n == s1.length == s2.length
 * 1 <= n, x <= 500
 * s1 and s2 consist only of the characters '0' and '1'.

Please complete the code below to solve above prblem:
```python
class Solution:
    def minOperations(self, s1: str, s2: str, x: int) -> int:

```


apply-operations-on-array-to-maximize-sum-of-squares

Apply Operations on Array to Maximize Sum of Squares

Prompt:
"""
You are given a 0-indexed integer array nums and a positive integer k.

You can do the following operation on the array any number of times:

 * Choose any two distinct indices i and j and simultaneously update the values of nums[i] to (nums[i] AND nums[j]) and nums[j] to (nums[i] OR nums[j]). Here, OR denotes the bitwise OR operation, and AND denotes the bitwise AND operation.

You have to choose k elements from the final array and calculate the sum of their squares.

Return the maximum sum of squares you can achieve.

Since the answer can be very large, return it modulo 109 + 7.

Example 1:

Input: nums = [2,6,5,8], k = 2
Output: 261
Explanation: We can do the following operations on the array:
- Choose i = 0 and j = 3, then change nums[0] to (2 AND 8) = 0 and nums[3] to (2 OR 8) = 10. The resulting array is nums = [0,6,5,10].
- Choose i = 2 and j = 3, then change nums[2] to (5 AND 10) = 0 and nums[3] to (5 OR 10) = 15. The resulting array is nums = [0,6,0,15].
We can choose the elements 15 and 6 from the final array. The sum of squares is 152 + 62 = 261.
It can be shown that this is the maximum value we can get.

Example 2:

Input: nums = [4,5,4,7], k = 3
Output: 90
Explanation: We do not need to apply any operations.
We can choose the elements 7, 5, and 4 with a sum of squares: 72 + 52 + 42 = 90.
It can be shown that this is the maximum value we can get.

Constraints:

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

You are given a 0-indexed integer array nums and a positive integer k.

You can do the following operation on the array any number of times:

 * Choose any two distinct indices i and j and simultaneously update the values of nums[i] to (nums[i] AND nums[j]) and nums[j] to (nums[i] OR nums[j]). Here, OR denotes the bitwise OR operation, and AND denotes the bitwise AND operation.

You have to choose k elements from the final array and calculate the sum of their squares.

Return the maximum sum of squares you can achieve.

Since the answer can be very large, return it modulo 109 + 7.

Example 1:

Input: nums = [2,6,5,8], k = 2
Output: 261
Explanation: We can do the following operations on the array:
- Choose i = 0 and j = 3, then change nums[0] to (2 AND 8) = 0 and nums[3] to (2 OR 8) = 10. The resulting array is nums = [0,6,5,10].
- Choose i = 2 and j = 3, then change nums[2] to (5 AND 10) = 0 and nums[3] to (5 OR 10) = 15. The resulting array is nums = [0,6,0,15].
We can choose the elements 15 and 6 from the final array. The sum of squares is 152 + 62 = 261.
It can be shown that this is the maximum value we can get.

Example 2:

Input: nums = [4,5,4,7], k = 3
Output: 90
Explanation: We do not need to apply any operations.
We can choose the elements 7, 5, and 4 with a sum of squares: 72 + 52 + 42 = 90.
It can be shown that this is the maximum value we can get.

Constraints:

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

Please complete the code below to solve above prblem:
```python
class Solution:
    def maxSum(self, nums: List[int], k: int) -> int:

```


maximum-value-of-an-ordered-triplet-i

Maximum Value of an Ordered Triplet I

Prompt:
"""
You are given a 0-indexed integer array nums.

Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.

The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].

Example 1:

Input: nums = [12,6,1,2,7]
Output: 77
Explanation: The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.
It can be shown that there are no ordered triplets of indices with a value greater than 77.

Example 2:

Input: nums = [1,10,3,4,19]
Output: 133
Explanation: The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.
It can be shown that there are no ordered triplets of indices with a value greater than 133.

Example 3:

Input: nums = [1,2,3]
Output: 0
Explanation: The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.

Constraints:

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

You are given a 0-indexed integer array nums.

Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.

The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].

Example 1:

Input: nums = [12,6,1,2,7]
Output: 77
Explanation: The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.
It can be shown that there are no ordered triplets of indices with a value greater than 77.

Example 2:

Input: nums = [1,10,3,4,19]
Output: 133
Explanation: The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.
It can be shown that there are no ordered triplets of indices with a value greater than 133.

Example 3:

Input: nums = [1,2,3]
Output: 0
Explanation: The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.

Constraints:

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

Please complete the code below to solve above prblem:
```python
class Solution:
    def maximumTripletValue(self, nums: List[int]) -> int:

```

my_solution = Solution()

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

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

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

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

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

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

test_input = { "nums": [18,15,8,13,10,9,17,10,2,16,17] }
assert my_solution.maximumTripletValue(**test_input) == 272

test_input = { "nums": [8,6,3,13,2,12,19,5,19,6,10,11,9] }
assert my_solution.maximumTripletValue(**test_input) == 266

test_input = { "nums": [6,11,12,12,7,9,2,11,12,4,19,14,16,8,16] }
assert my_solution.maximumTripletValue(**test_input) == 190

test_input = { "nums": [15,14,17,13,18,17,10,19,2,20,12,9] }
assert my_solution.maximumTripletValue(**test_input) == 340

test_input = { "nums": [6,14,20,19,19,10,3,15,12,13,8,1,2,15,3] }
assert my_solution.maximumTripletValue(**test_input) == 285

test_input = { "nums": [2,7,19,4,8,20] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [10,13,6,2] }
assert my_solution.maximumTripletValue(**test_input) == 14

test_input = { "nums": [1,19,1,3,18,10,16,9,3,17,8,9] }
assert my_solution.maximumTripletValue(**test_input) == 324

test_input = { "nums": [16,2,10,20,16,2,13,8,19] }
assert my_solution.maximumTripletValue(**test_input) == 342

test_input = { "nums": [19,11,12,4,17,1,7,20,13,10,14,20,11,19,3] }
assert my_solution.maximumTripletValue(**test_input) == 360

test_input = { "nums": [16,15,12,5,4,12,15,17,5,18,6,16,1,17,4] }
assert my_solution.maximumTripletValue(**test_input) == 289

test_input = { "nums": [8,10,17,11,2,8,13] }
assert my_solution.maximumTripletValue(**test_input) == 195

test_input = { "nums": [13,4,3,19,16,14,17,6,20,6,16,4] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [1,8,9,18,4,10,3,13,9] }
assert my_solution.maximumTripletValue(**test_input) == 195

test_input = { "nums": [10,10,5,19,2] }
assert my_solution.maximumTripletValue(**test_input) == 95

test_input = { "nums": [15,3,3,18,19,13,7,5,18,1,8,5] }
assert my_solution.maximumTripletValue(**test_input) == 252

test_input = { "nums": [10,20,10] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [14,9,4,20,9] }
assert my_solution.maximumTripletValue(**test_input) == 200

test_input = { "nums": [12,20,5,2,13,17,16,1,5,8,18,15,12] }
assert my_solution.maximumTripletValue(**test_input) == 342

test_input = { "nums": [7,1,17,17,4,20,14,20] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [16,19,8,8,5,18,12,16,8,14,14,7,19] }
assert my_solution.maximumTripletValue(**test_input) == 266

test_input = { "nums": [17,9,13,7,3,5] }
assert my_solution.maximumTripletValue(**test_input) == 104

test_input = { "nums": [15,12,2,14,15,18,15,20,14,5,14,14,11,13,7] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [17,20,17,13,5,12,8,12,14,10,14,20] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [1,19,10] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [11,16,10,15,10,5,7,3] }
assert my_solution.maximumTripletValue(**test_input) == 90

test_input = { "nums": [5,14,19,12,2,5,18,3,20,12,1,11] }
assert my_solution.maximumTripletValue(**test_input) == 340

test_input = { "nums": [10,8,12,14] }
assert my_solution.maximumTripletValue(**test_input) == 28

test_input = { "nums": [2,17,18,16,14,20,11,3,18,5,20,6,7] }
assert my_solution.maximumTripletValue(**test_input) == 340

test_input = { "nums": [19,12,3,19,2,18,3,12,9] }
assert my_solution.maximumTripletValue(**test_input) == 306

test_input = { "nums": [12,9,11,2,11,3,11,17,13,19] }
assert my_solution.maximumTripletValue(**test_input) == 190

test_input = { "nums": [8,13,9,8,7,18,20] }
assert my_solution.maximumTripletValue(**test_input) == 120

test_input = { "nums": [20,8,12,1,7,8,3,3,6] }
assert my_solution.maximumTripletValue(**test_input) == 152

test_input = { "nums": [8,2,16,6,14,14,13,2,11,5,2,12,15,3,3] }
assert my_solution.maximumTripletValue(**test_input) == 210

test_input = { "nums": [19,9,9,9,5] }
assert my_solution.maximumTripletValue(**test_input) == 90

test_input = { "nums": [19,10,5,13,6,9,5,15,19] }
assert my_solution.maximumTripletValue(**test_input) == 266

test_input = { "nums": [14,18,17,8,2,8,14] }
assert my_solution.maximumTripletValue(**test_input) == 224

test_input = { "nums": [11,5,17,13,5,8,8,19,17,1] }
assert my_solution.maximumTripletValue(**test_input) == 228

test_input = { "nums": [18,12,18,14,17,19] }
assert my_solution.maximumTripletValue(**test_input) == 114

test_input = { "nums": [18,17,8,8,18,9] }
assert my_solution.maximumTripletValue(**test_input) == 180

test_input = { "nums": [15,3,2,10,11,10,13,18] }
assert my_solution.maximumTripletValue(**test_input) == 234

test_input = { "nums": [17,17,5,10,19,1,16,3,1,19] }
assert my_solution.maximumTripletValue(**test_input) == 342

test_input = { "nums": [1,18,4,20,16] }
assert my_solution.maximumTripletValue(**test_input) == 280

test_input = { "nums": [6,20,4,4,2,19,14,10,9,7,20,5,8] }
assert my_solution.maximumTripletValue(**test_input) == 360

test_input = { "nums": [5,14,15,18,2,9,15,13,11,16,12,20] }
assert my_solution.maximumTripletValue(**test_input) == 320

test_input = { "nums": [7,19,17] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [5,7,14,18,13,11,15,20,8,11,12,4,17,2,16] }
assert my_solution.maximumTripletValue(**test_input) == 288

test_input = { "nums": [4,12,7,2,8,6,9,5,4,1,8] }
assert my_solution.maximumTripletValue(**test_input) == 90

test_input = { "nums": [11,17,2,18,5] }
assert my_solution.maximumTripletValue(**test_input) == 270

test_input = { "nums": [19,13,2,2,19] }
assert my_solution.maximumTripletValue(**test_input) == 323

test_input = { "nums": [14,11,7,6,2,20,16,14,4,12,1,9,16,7,10] }
assert my_solution.maximumTripletValue(**test_input) == 304

test_input = { "nums": [8,15,6,16,16,9,6,14,4] }
assert my_solution.maximumTripletValue(**test_input) == 144

test_input = { "nums": [16,19,1,7,18,6,18,5,19,18,19] }
assert my_solution.maximumTripletValue(**test_input) == 342

test_input = { "nums": [16,14,11,2,17,9,10] }
assert my_solution.maximumTripletValue(**test_input) == 238

test_input = { "nums": [3,4,18,2,20,1,1,16,15,8,7,14,19,6] }
assert my_solution.maximumTripletValue(**test_input) == 361

test_input = { "nums": [12,20,14,18,11,16,16,9,12,5,14,17] }
assert my_solution.maximumTripletValue(**test_input) == 255

test_input = { "nums": [12,19,2,9,6] }
assert my_solution.maximumTripletValue(**test_input) == 153

test_input = { "nums": [17,19,14,7,10,18] }
assert my_solution.maximumTripletValue(**test_input) == 216

test_input = { "nums": [3,4,19,10,16,13,6,20] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [11,6,8,9] }
assert my_solution.maximumTripletValue(**test_input) == 45

test_input = { "nums": [7,12,9,19,10,18,16,2,1,3,7,9,7,7] }
assert my_solution.maximumTripletValue(**test_input) == 162

test_input = { "nums": [20,9,20,7,3,7,19] }
assert my_solution.maximumTripletValue(**test_input) == 323

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

test_input = { "nums": [4,20,15,1,17,2,2,4,10,15,2,8,16,6] }
assert my_solution.maximumTripletValue(**test_input) == 323

test_input = { "nums": [15,10,1,18,18,16,7,13,9,11] }
assert my_solution.maximumTripletValue(**test_input) == 252

test_input = { "nums": [10,6,17,11,15,15,18] }
assert my_solution.maximumTripletValue(**test_input) == 108

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

test_input = { "nums": [4,7,20] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [16,12,5] }
assert my_solution.maximumTripletValue(**test_input) == 20

test_input = { "nums": [4,17,15,12,2,16,16,13,6,20,14,17,18,16] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [1,7,18,3,1,11,7,17] }
assert my_solution.maximumTripletValue(**test_input) == 289

test_input = { "nums": [18,16,10,2] }
assert my_solution.maximumTripletValue(**test_input) == 20

test_input = { "nums": [3,10,18,10,7,8] }
assert my_solution.maximumTripletValue(**test_input) == 88

test_input = { "nums": [8,6,20,20,4,12,14,7,13,16,12,15,12] }
assert my_solution.maximumTripletValue(**test_input) == 256

test_input = { "nums": [5,19,11,18,19,14,8,11,4,10] }
assert my_solution.maximumTripletValue(**test_input) == 152

test_input = { "nums": [17,1,16] }
assert my_solution.maximumTripletValue(**test_input) == 256

test_input = { "nums": [20,8,17,14,15,2,7,9,1,10,10,4,19,2,1] }
assert my_solution.maximumTripletValue(**test_input) == 361

test_input = { "nums": [9,16,16] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [2,16,2,19,5,20,2,20,6,6] }
assert my_solution.maximumTripletValue(**test_input) == 360

test_input = { "nums": [18,3,6,17,4,20,14,6,13,9,5,11] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [12,2,19,15,4,3,18,6,11,9,9,6,15] }
assert my_solution.maximumTripletValue(**test_input) == 288

test_input = { "nums": [10,15,10,13,7,18,18,3,13,15,20,4,6,15] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [10,15,4,19,6,17,7,10,4,12,14,16,9,14] }
assert my_solution.maximumTripletValue(**test_input) == 240

test_input = { "nums": [17,6,3,8,13] }
assert my_solution.maximumTripletValue(**test_input) == 182

test_input = { "nums": [6,18,8,8,16,14,7,18] }
assert my_solution.maximumTripletValue(**test_input) == 198

test_input = { "nums": [7,7,2,19,16,11,3,15,3,15,16,17] }
assert my_solution.maximumTripletValue(**test_input) == 272

test_input = { "nums": [9,3,3,12,9,12,5,7,6,2,9,9,14,9,5] }
assert my_solution.maximumTripletValue(**test_input) == 140

test_input = { "nums": [19,14,15,1,20,10,20,4,10,20,15,15,2,7] }
assert my_solution.maximumTripletValue(**test_input) == 360

test_input = { "nums": [17,4,10,16,8,20,4,9,11,15,2,7] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [3,8,17,10,10,20,20,8,14,20,1,10,1] }
assert my_solution.maximumTripletValue(**test_input) == 240

test_input = { "nums": [3,4,11,18,10,19,9,11,14,11,18,15,17,19,3] }
assert my_solution.maximumTripletValue(**test_input) == 190

test_input = { "nums": [18,10,5,16,13,1,19,10,17,14,14,20] }
assert my_solution.maximumTripletValue(**test_input) == 340

test_input = { "nums": [18,3,16,14,15,9,13,2,3] }
assert my_solution.maximumTripletValue(**test_input) == 240

test_input = { "nums": [2,6,19,10,19,14,18,8,3,2] }
assert my_solution.maximumTripletValue(**test_input) == 171


maximum-value-of-an-ordered-triplet-ii

Maximum Value of an Ordered Triplet II

Prompt:
"""
You are given a 0-indexed integer array nums.

Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.

The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].

Example 1:

Input: nums = [12,6,1,2,7]
Output: 77
Explanation: The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.
It can be shown that there are no ordered triplets of indices with a value greater than 77.

Example 2:

Input: nums = [1,10,3,4,19]
Output: 133
Explanation: The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.
It can be shown that there are no ordered triplets of indices with a value greater than 133.

Example 3:

Input: nums = [1,2,3]
Output: 0
Explanation: The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.

Constraints:

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

You are given a 0-indexed integer array nums.

Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.

The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].

Example 1:

Input: nums = [12,6,1,2,7]
Output: 77
Explanation: The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.
It can be shown that there are no ordered triplets of indices with a value greater than 77.

Example 2:

Input: nums = [1,10,3,4,19]
Output: 133
Explanation: The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.
It can be shown that there are no ordered triplets of indices with a value greater than 133.

Example 3:

Input: nums = [1,2,3]
Output: 0
Explanation: The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.

Constraints:

 * 3 <= nums.length <= 105
 * 1 <= nums[i] <= 106

Please complete the code below to solve above prblem:
```python
class Solution:
    def maximumTripletValue(self, nums: List[int]) -> int:

```

my_solution = Solution()

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

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

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

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

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

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

test_input = { "nums": [18,15,8,13,10,9,17,10,2,16,17] }
assert my_solution.maximumTripletValue(**test_input) == 272

test_input = { "nums": [8,6,3,13,2,12,19,5,19,6,10,11,9] }
assert my_solution.maximumTripletValue(**test_input) == 266

test_input = { "nums": [6,11,12,12,7,9,2,11,12,4,19,14,16,8,16] }
assert my_solution.maximumTripletValue(**test_input) == 190

test_input = { "nums": [15,14,17,13,18,17,10,19,2,20,12,9] }
assert my_solution.maximumTripletValue(**test_input) == 340

test_input = { "nums": [6,14,20,19,19,10,3,15,12,13,8,1,2,15,3] }
assert my_solution.maximumTripletValue(**test_input) == 285

test_input = { "nums": [2,7,19,4,8,20] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [10,13,6,2] }
assert my_solution.maximumTripletValue(**test_input) == 14

test_input = { "nums": [1,19,1,3,18,10,16,9,3,17,8,9] }
assert my_solution.maximumTripletValue(**test_input) == 324

test_input = { "nums": [16,2,10,20,16,2,13,8,19] }
assert my_solution.maximumTripletValue(**test_input) == 342

test_input = { "nums": [19,11,12,4,17,1,7,20,13,10,14,20,11,19,3] }
assert my_solution.maximumTripletValue(**test_input) == 360

test_input = { "nums": [16,15,12,5,4,12,15,17,5,18,6,16,1,17,4] }
assert my_solution.maximumTripletValue(**test_input) == 289

test_input = { "nums": [8,10,17,11,2,8,13] }
assert my_solution.maximumTripletValue(**test_input) == 195

test_input = { "nums": [13,4,3,19,16,14,17,6,20,6,16,4] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [1,8,9,18,4,10,3,13,9] }
assert my_solution.maximumTripletValue(**test_input) == 195

test_input = { "nums": [10,10,5,19,2] }
assert my_solution.maximumTripletValue(**test_input) == 95

test_input = { "nums": [15,3,3,18,19,13,7,5,18,1,8,5] }
assert my_solution.maximumTripletValue(**test_input) == 252

test_input = { "nums": [10,20,10] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [14,9,4,20,9] }
assert my_solution.maximumTripletValue(**test_input) == 200

test_input = { "nums": [12,20,5,2,13,17,16,1,5,8,18,15,12] }
assert my_solution.maximumTripletValue(**test_input) == 342

test_input = { "nums": [7,1,17,17,4,20,14,20] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [16,19,8,8,5,18,12,16,8,14,14,7,19] }
assert my_solution.maximumTripletValue(**test_input) == 266

test_input = { "nums": [17,9,13,7,3,5] }
assert my_solution.maximumTripletValue(**test_input) == 104

test_input = { "nums": [15,12,2,14,15,18,15,20,14,5,14,14,11,13,7] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [17,20,17,13,5,12,8,12,14,10,14,20] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [1,19,10] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [11,16,10,15,10,5,7,3] }
assert my_solution.maximumTripletValue(**test_input) == 90

test_input = { "nums": [5,14,19,12,2,5,18,3,20,12,1,11] }
assert my_solution.maximumTripletValue(**test_input) == 340

test_input = { "nums": [10,8,12,14] }
assert my_solution.maximumTripletValue(**test_input) == 28

test_input = { "nums": [2,17,18,16,14,20,11,3,18,5,20,6,7] }
assert my_solution.maximumTripletValue(**test_input) == 340

test_input = { "nums": [19,12,3,19,2,18,3,12,9] }
assert my_solution.maximumTripletValue(**test_input) == 306

test_input = { "nums": [12,9,11,2,11,3,11,17,13,19] }
assert my_solution.maximumTripletValue(**test_input) == 190

test_input = { "nums": [8,13,9,8,7,18,20] }
assert my_solution.maximumTripletValue(**test_input) == 120

test_input = { "nums": [20,8,12,1,7,8,3,3,6] }
assert my_solution.maximumTripletValue(**test_input) == 152

test_input = { "nums": [8,2,16,6,14,14,13,2,11,5,2,12,15,3,3] }
assert my_solution.maximumTripletValue(**test_input) == 210

test_input = { "nums": [19,9,9,9,5] }
assert my_solution.maximumTripletValue(**test_input) == 90

test_input = { "nums": [19,10,5,13,6,9,5,15,19] }
assert my_solution.maximumTripletValue(**test_input) == 266

test_input = { "nums": [14,18,17,8,2,8,14] }
assert my_solution.maximumTripletValue(**test_input) == 224

test_input = { "nums": [11,5,17,13,5,8,8,19,17,1] }
assert my_solution.maximumTripletValue(**test_input) == 228

test_input = { "nums": [18,12,18,14,17,19] }
assert my_solution.maximumTripletValue(**test_input) == 114

test_input = { "nums": [18,17,8,8,18,9] }
assert my_solution.maximumTripletValue(**test_input) == 180

test_input = { "nums": [15,3,2,10,11,10,13,18] }
assert my_solution.maximumTripletValue(**test_input) == 234

test_input = { "nums": [17,17,5,10,19,1,16,3,1,19] }
assert my_solution.maximumTripletValue(**test_input) == 342

test_input = { "nums": [1,18,4,20,16] }
assert my_solution.maximumTripletValue(**test_input) == 280

test_input = { "nums": [6,20,4,4,2,19,14,10,9,7,20,5,8] }
assert my_solution.maximumTripletValue(**test_input) == 360

test_input = { "nums": [5,14,15,18,2,9,15,13,11,16,12,20] }
assert my_solution.maximumTripletValue(**test_input) == 320

test_input = { "nums": [7,19,17] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [5,7,14,18,13,11,15,20,8,11,12,4,17,2,16] }
assert my_solution.maximumTripletValue(**test_input) == 288

test_input = { "nums": [4,12,7,2,8,6,9,5,4,1,8] }
assert my_solution.maximumTripletValue(**test_input) == 90

test_input = { "nums": [11,17,2,18,5] }
assert my_solution.maximumTripletValue(**test_input) == 270

test_input = { "nums": [19,13,2,2,19] }
assert my_solution.maximumTripletValue(**test_input) == 323

test_input = { "nums": [14,11,7,6,2,20,16,14,4,12,1,9,16,7,10] }
assert my_solution.maximumTripletValue(**test_input) == 304

test_input = { "nums": [8,15,6,16,16,9,6,14,4] }
assert my_solution.maximumTripletValue(**test_input) == 144

test_input = { "nums": [16,19,1,7,18,6,18,5,19,18,19] }
assert my_solution.maximumTripletValue(**test_input) == 342

test_input = { "nums": [16,14,11,2,17,9,10] }
assert my_solution.maximumTripletValue(**test_input) == 238

test_input = { "nums": [3,4,18,2,20,1,1,16,15,8,7,14,19,6] }
assert my_solution.maximumTripletValue(**test_input) == 361

test_input = { "nums": [12,20,14,18,11,16,16,9,12,5,14,17] }
assert my_solution.maximumTripletValue(**test_input) == 255

test_input = { "nums": [12,19,2,9,6] }
assert my_solution.maximumTripletValue(**test_input) == 153

test_input = { "nums": [17,19,14,7,10,18] }
assert my_solution.maximumTripletValue(**test_input) == 216

test_input = { "nums": [3,4,19,10,16,13,6,20] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [11,6,8,9] }
assert my_solution.maximumTripletValue(**test_input) == 45

test_input = { "nums": [7,12,9,19,10,18,16,2,1,3,7,9,7,7] }
assert my_solution.maximumTripletValue(**test_input) == 162

test_input = { "nums": [20,9,20,7,3,7,19] }
assert my_solution.maximumTripletValue(**test_input) == 323

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

test_input = { "nums": [4,20,15,1,17,2,2,4,10,15,2,8,16,6] }
assert my_solution.maximumTripletValue(**test_input) == 323

test_input = { "nums": [15,10,1,18,18,16,7,13,9,11] }
assert my_solution.maximumTripletValue(**test_input) == 252

test_input = { "nums": [10,6,17,11,15,15,18] }
assert my_solution.maximumTripletValue(**test_input) == 108

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

test_input = { "nums": [4,7,20] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [16,12,5] }
assert my_solution.maximumTripletValue(**test_input) == 20

test_input = { "nums": [4,17,15,12,2,16,16,13,6,20,14,17,18,16] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [1,7,18,3,1,11,7,17] }
assert my_solution.maximumTripletValue(**test_input) == 289

test_input = { "nums": [18,16,10,2] }
assert my_solution.maximumTripletValue(**test_input) == 20

test_input = { "nums": [3,10,18,10,7,8] }
assert my_solution.maximumTripletValue(**test_input) == 88

test_input = { "nums": [8,6,20,20,4,12,14,7,13,16,12,15,12] }
assert my_solution.maximumTripletValue(**test_input) == 256

test_input = { "nums": [5,19,11,18,19,14,8,11,4,10] }
assert my_solution.maximumTripletValue(**test_input) == 152

test_input = { "nums": [17,1,16] }
assert my_solution.maximumTripletValue(**test_input) == 256

test_input = { "nums": [20,8,17,14,15,2,7,9,1,10,10,4,19,2,1] }
assert my_solution.maximumTripletValue(**test_input) == 361

test_input = { "nums": [9,16,16] }
assert my_solution.maximumTripletValue(**test_input) == 0

test_input = { "nums": [2,16,2,19,5,20,2,20,6,6] }
assert my_solution.maximumTripletValue(**test_input) == 360

test_input = { "nums": [18,3,6,17,4,20,14,6,13,9,5,11] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [12,2,19,15,4,3,18,6,11,9,9,6,15] }
assert my_solution.maximumTripletValue(**test_input) == 288

test_input = { "nums": [10,15,10,13,7,18,18,3,13,15,20,4,6,15] }
assert my_solution.maximumTripletValue(**test_input) == 300

test_input = { "nums": [10,15,4,19,6,17,7,10,4,12,14,16,9,14] }
assert my_solution.maximumTripletValue(**test_input) == 240

test_input = { "nums": [17,6,3,8,13] }
assert my_solution.maximumTripletValue(**test_input) == 182

test_input = { "nums": [6,18,8,8,16,14,7,18] }
assert my_solution.maximumTripletValue(**test_input) == 198

test_input = { "nums": [7,7,2,19,16,11,3,15,3,15,16,17] }
assert my_solution.maximumTripletValue(**test_input) == 272

test_input = { "nums": [9,3,3,12,9,12,5,7,6,2,9,9,14,9,5] }
assert my_solution.maximumTripletValue(**test_input) == 140

test_input = { "nums": [19,14,15,1,20,10,20,4,10,20,15,15,2,7] }
assert my_solution.maximumTripletValue(**test_input) == 360

test_input = { "nums": [17,4,10,16,8,20,4,9,11,15,2,7] }
assert my_solution.maximumTripletValue(**test_input) == 260

test_input = { "nums": [3,8,17,10,10,20,20,8,14,20,1,10,1] }
assert my_solution.maximumTripletValue(**test_input) == 240

test_input = { "nums": [3,4,11,18,10,19,9,11,14,11,18,15,17,19,3] }
assert my_solution.maximumTripletValue(**test_input) == 190

test_input = { "nums": [18,10,5,16,13,1,19,10,17,14,14,20] }
assert my_solution.maximumTripletValue(**test_input) == 340

test_input = { "nums": [18,3,16,14,15,9,13,2,3] }
assert my_solution.maximumTripletValue(**test_input) == 240

test_input = { "nums": [2,6,19,10,19,14,18,8,3,2] }
assert my_solution.maximumTripletValue(**test_input) == 171


minimum-size-subarray-in-infinite-array

Minimum Size Subarray in Infinite Array

Prompt:
"""
You are given a 0-indexed array nums and an integer target.

A 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itself.

Return the length of the shortest subarray of the array infinite_nums with a sum equal to target. If there is no such subarray return -1.

Example 1:

Input: nums = [1,2,3], target = 5
Output: 2
Explanation: In this example infinite_nums = [1,2,3,1,2,3,1,2,...].
The subarray in the range [1,2], has the sum equal to target = 5 and length = 2.
It can be proven that 2 is the shortest length of a subarray with sum equal to target = 5.

Example 2:

Input: nums = [1,1,1,2,3], target = 4
Output: 2
Explanation: In this example infinite_nums = [1,1,1,2,3,1,1,1,2,3,1,1,...].
The subarray in the range [4,5], has the sum equal to target = 4 and length = 2.
It can be proven that 2 is the shortest length of a subarray with sum equal to target = 4.

Example 3:

Input: nums = [2,4,6,8], target = 3
Output: -1
Explanation: In this example infinite_nums = [2,4,6,8,2,4,6,8,...].
It can be proven that there is no subarray with sum equal to target = 3.

Constraints:

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

You are given a 0-indexed array nums and an integer target.

A 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itself.

Return the length of the shortest subarray of the array infinite_nums with a sum equal to target. If there is no such subarray return -1.

Example 1:

Input: nums = [1,2,3], target = 5
Output: 2
Explanation: In this example infinite_nums = [1,2,3,1,2,3,1,2,...].
The subarray in the range [1,2], has the sum equal to target = 5 and length = 2.
It can be proven that 2 is the shortest length of a subarray with sum equal to target = 5.

Example 2:

Input: nums = [1,1,1,2,3], target = 4
Output: 2
Explanation: In this example infinite_nums = [1,1,1,2,3,1,1,1,2,3,1,1,...].
The subarray in the range [4,5], has the sum equal to target = 4 and length = 2.
It can be proven that 2 is the shortest length of a subarray with sum equal to target = 4.

Example 3:

Input: nums = [2,4,6,8], target = 3
Output: -1
Explanation: In this example infinite_nums = [2,4,6,8,2,4,6,8,...].
It can be proven that there is no subarray with sum equal to target = 3.

Constraints:

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

Please complete the code below to solve above prblem:
```python
class Solution:
    def minSizeSubarray(self, nums: List[int], target: int) -> int:

```

my_solution = Solution()

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

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

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

test_input = { "nums": [2,1,5,7,7,1,6,3], "target": 39 }
assert my_solution.minSizeSubarray(**test_input) == 9

test_input = { "nums": [17,4,3,14,17,6,15], "target": 85 }
assert my_solution.minSizeSubarray(**test_input) == -1

test_input = { "nums": [18,3,11,19,7,16,6,7,3,6,18,9,9,1,14,17,15,14,12,10], "target": 7 }
assert my_solution.minSizeSubarray(**test_input) == 1

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

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

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

test_input = { "nums": [1,11,6,4,13], "target": 22 }
assert my_solution.minSizeSubarray(**test_input) == 4

test_input = { "nums": [1,2,2,2,1,2,1,2,1,2,1], "target": 83 }
assert my_solution.minSizeSubarray(**test_input) == 53

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

test_input = { "nums": [1,2,3,2,1,5,3,4,5], "target": 53 }
assert my_solution.minSizeSubarray(**test_input) == 19

test_input = { "nums": [2,5,6,4], "target": 95 }
assert my_solution.minSizeSubarray(**test_input) == 22

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

test_input = { "nums": [1,2,8,19,17,2,3,11,8,12,16,18,7], "target": 36 }
assert my_solution.minSizeSubarray(**test_input) == 2

test_input = { "nums": [12,14,4,14,13,16,5], "target": 36 }
assert my_solution.minSizeSubarray(**test_input) == -1

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

test_input = { "nums": [5,7,2,6,4,1,6,7,1,4,7,6,7,7,6,6,4,6,8], "target": 90 }
assert my_solution.minSizeSubarray(**test_input) == 17

test_input = { "nums": [3,5,15,17,6,17,10,15,10,4,6], "target": 25 }
assert my_solution.minSizeSubarray(**test_input) == 2

test_input = { "nums": [14,5], "target": 23 }
assert my_solution.minSizeSubarray(**test_input) == -1

test_input = { "nums": [1,1,5,9], "target": 68 }
assert my_solution.minSizeSubarray(**test_input) == -1

test_input = { "nums": [11,1,17,14,9,16,5,3,7,16,14,18,17,10], "target": 82 }
assert my_solution.minSizeSubarray(**test_input) == 6

test_input = { "nums": [9,6,8,4,3,4,6,4,7,2,6,9,2,4,5,4], "target": 71 }
assert my_solution.minSizeSubarray(**test_input) == 14

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

test_input = { "nums": [3,6], "target": 66 }
assert my_solution.minSizeSubarray(**test_input) == 15

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

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

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

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

test_input = { "nums": [5,1,4,1,5,6], "target": 71 }
assert my_solution.minSizeSubarray(**test_input) == 19

test_input = { "nums": [3,5,6,6,1,8,4,9,6,2,3,9,6,8,7,3,6,1,8,6], "target": 60 }
assert my_solution.minSizeSubarray(**test_input) == 11

test_input = { "nums": [12,15,9,3,3,12,13,14,7,11,7,15,12,5,11], "target": 18 }
assert my_solution.minSizeSubarray(**test_input) == 2

test_input = { "nums": [3,11,10,12,9,13,9], "target": 19 }
assert my_solution.minSizeSubarray(**test_input) == -1

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

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

test_input = { "nums": [2,13,15,3,6,7,16,7,9,10,4,3,12,9,13,2,9,13,15], "target": 4 }
assert my_solution.minSizeSubarray(**test_input) == 1

test_input = { "nums": [1,2,16,10,15,15,13,11,10,6,12,15,9], "target": 30 }
assert my_solution.minSizeSubarray(**test_input) == 2

test_input = { "nums": [3,5], "target": 85 }
assert my_solution.minSizeSubarray(**test_input) == 21

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

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

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

test_input = { "nums": [19,18,6], "target": 56 }
assert my_solution.minSizeSubarray(**test_input) == -1

test_input = { "nums": [3,5,7,6,5,3,7,7,1,5,3,1,5,6,3,1,6,1,3], "target": 20 }
assert my_solution.minSizeSubarray(**test_input) == 4

test_input = { "nums": [5,5,4,1,2,2,2,3,2,4,2,5], "target": 56 }
assert my_solution.minSizeSubarray(**test_input) == 16

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

test_input = { "nums": [1,2], "target": 72 }
assert my_solution.minSizeSubarray(**test_input) == 48

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

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

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

test_input = { "nums": [18,12,13,9,17,11], "target": 82 }
assert my_solution.minSizeSubarray(**test_input) == -1

test_input = { "nums": [13,3,1,5,13,7,12,5], "target": 35 }
assert my_solution.minSizeSubarray(**test_input) == 5

test_input = { "nums": [4,10,12,6,2,2,4,12,6,1,1,2,2,10,6,11,5,4,9], "target": 49 }
assert my_solution.minSizeSubarray(**test_input) == 7

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

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

test_input = { "nums": [4,7,6,12,10,13,7,6,6,1,15,2,4,8,12], "target": 43 }
assert my_solution.minSizeSubarray(**test_input) == 6

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

test_input = { "nums": [4,3,2,4,5,3,7,12,2,2,10], "target": 43 }
assert my_solution.minSizeSubarray(**test_input) == 8

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

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

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

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

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

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

test_input = { "nums": [10,12,1,11,9,5,4,5,1,10,8,12,5,4], "target": 82 }
assert my_solution.minSizeSubarray(**test_input) == 10

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

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

test_input = { "nums": [14,4,13,12,18,8,4,15,4,14,17,4,2], "target": 8 }
assert my_solution.minSizeSubarray(**test_input) == 1

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

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

test_input = { "nums": [5,10,1,3,14,7,13,6,5,7,10,3,10,5,8,5,7,5,6,7], "target": 25 }
assert my_solution.minSizeSubarray(**test_input) == 4

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

test_input = { "nums": [3,11,5,5,3,10,12,12,12,3,10], "target": 88 }
assert my_solution.minSizeSubarray(**test_input) == -1

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

test_input = { "nums": [3,5,1,4,5,2,5,3,1,2,1,1,1,3,3,3,5], "target": 68 }
assert my_solution.minSizeSubarray(**test_input) == 23

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

test_input = { "nums": [15,8,8,19,8,12,15,3,15,8,10,9], "target": 77 }
assert my_solution.minSizeSubarray(**test_input) == 7

test_input = { "nums": [4,4], "target": 80 }
assert my_solution.minSizeSubarray(**test_input) == 20

test_input = { "nums": [4,9,3,7,5,4,5,1,3,5], "target": 69 }
assert my_solution.minSizeSubarray(**test_input) == 14

test_input = { "nums": [2,8,2,8,1,5,8,9,3,4,6,6,6,1,7,9], "target": 93 }
assert my_solution.minSizeSubarray(**test_input) == 17

test_input = { "nums": [7,11,14,12,3,16,11,9], "target": 10 }
assert my_solution.minSizeSubarray(**test_input) == -1

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

test_input = { "nums": [5,20,18,2,8], "target": 45 }
assert my_solution.minSizeSubarray(**test_input) == 4

test_input = { "nums": [2,1,2,1,2,1,1,1,2,2], "target": 58 }
assert my_solution.minSizeSubarray(**test_input) == 38

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

test_input = { "nums": [18,6,8,17,3,10,14,12,4,13,12,10,5,18,11], "target": 95 }
assert my_solution.minSizeSubarray(**test_input) == 9

test_input = { "nums": [19,12,14], "target": 57 }
assert my_solution.minSizeSubarray(**test_input) == 4

test_input = { "nums": [3,13,14], "target": 11 }
assert my_solution.minSizeSubarray(**test_input) == -1

test_input = { "nums": [17,6,8,7,4,6,6,3,8,1,8,10,18,13,2], "target": 32 }
assert my_solution.minSizeSubarray(**test_input) == 3

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

test_input = { "nums": [3,14,2,9,5,14,15,4,3,4,17,11], "target": 3 }
assert my_solution.minSizeSubarray(**test_input) == 1

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

test_input = { "nums": [13,6,4,7,3,6,4,10,13,10,5,4,2,1,7,11,3,3,12], "target": 51 }
assert my_solution.minSizeSubarray(**test_input) == 7

test_input = { "nums": [1,10,9,16,3,10,2,5,1,10], "target": 83 }
assert my_solution.minSizeSubarray(**test_input) == 11

test_input = { "nums": [2,10,13,3,4,19,14,20,11,15,4,3,17,8,2,3,1,13,8], "target": 1 }
assert my_solution.minSizeSubarray(**test_input) == 1

test_input = { "nums": [4,5,5,3,5,4,2,11,5,9,4,6], "target": 41 }
assert my_solution.minSizeSubarray(**test_input) == 7

test_input = { "nums": [2,8,9,6,11,17,3,6,9,7,2,8,9,11,19], "target": 39 }
assert my_solution.minSizeSubarray(**test_input) == 3

test_input = { "nums": [8,13,9,5,8,6,17,16,14,7,10,15,16], "target": 8 }
assert my_solution.minSizeSubarray(**test_input) == 1

test_input = { "nums": [10,20,16,1,11,18,13,6,13,6,9,14,16,12,13,7,19], "target": 59 }
assert my_solution.minSizeSubarray(**test_input) == 5

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