longest-unequal-adjacent-groups-subsequence-i

Longest Unequal Adjacent Groups Subsequence I

Prompt:
"""
给你一个整数 n 和一个下标从 0 开始的字符串数组 words ，和一个下标从 0 开始的 二进制 数组 groups ，两个数组长度都是 n 。

你需要从下标 [0, 1, ..., n - 1] 中选出一个 最长子序列 ，将这个子序列记作长度为 k 的 [i0, i1, ..., ik - 1] ，对于所有满足 0 < j + 1 < k 的 j 都有 groups[ij] != groups[ij + 1] 。

请你返回一个字符串数组，它是下标子序列 依次 对应 words 数组中的字符串连接形成的字符串数组。如果有多个答案，返回任意一个。

子序列 指的是从原数组中删掉一些（也可能一个也不删掉）元素，剩余元素不改变相对位置得到的新的数组。

注意：words 中的字符串长度可能 不相等 。

示例 1：

输入：n = 3, words = ["e","a","b"], groups = [0,0,1]
输出：["e","b"]
解释：一个可行的子序列是 [0,2] ，因为 groups[0] != groups[2] 。
所以一个可行的答案是 [words[0],words[2]] = ["e","b"] 。
另一个可行的子序列是 [1,2] ，因为 groups[1] != groups[2] 。
得到答案为 [words[1],words[2]] = ["a","b"] 。
这也是一个可行的答案。
符合题意的最长子序列的长度为 2 。

示例 2：

输入：n = 4, words = ["a","b","c","d"], groups = [1,0,1,1]
输出：["a","b","c"]
解释：一个可行的子序列为 [0,1,2] 因为 groups[0] != groups[1] 且 groups[1] != groups[2] 。
所以一个可行的答案是 [words[0],words[1],words[2]] = ["a","b","c"] 。
另一个可行的子序列为 [0,1,3] 因为 groups[0] != groups[1] 且 groups[1] != groups[3] 。
得到答案为 [words[0],words[1],words[3]] = ["a","b","d"] 。
这也是一个可行的答案。
符合题意的最长子序列的长度为 3 。

提示：

 * 1 <= n == words.length == groups.length <= 100
 * 1 <= words[i].length <= 10
 * 0 <= groups[i] < 2
 * words 中的字符串 互不相同 。
 * words[i] 只包含小写英文字母。
"""
class Solution:
    def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:

给你一个整数 n 和一个下标从 0 开始的字符串数组 words ，和一个下标从 0 开始的 二进制 数组 groups ，两个数组长度都是 n 。

你需要从下标 [0, 1, ..., n - 1] 中选出一个 最长子序列 ，将这个子序列记作长度为 k 的 [i0, i1, ..., ik - 1] ，对于所有满足 0 < j + 1 < k 的 j 都有 groups[ij] != groups[ij + 1] 。

请你返回一个字符串数组，它是下标子序列 依次 对应 words 数组中的字符串连接形成的字符串数组。如果有多个答案，返回任意一个。

子序列 指的是从原数组中删掉一些（也可能一个也不删掉）元素，剩余元素不改变相对位置得到的新的数组。

注意：words 中的字符串长度可能 不相等 。

示例 1：

输入：n = 3, words = ["e","a","b"], groups = [0,0,1]
输出：["e","b"]
解释：一个可行的子序列是 [0,2] ，因为 groups[0] != groups[2] 。
所以一个可行的答案是 [words[0],words[2]] = ["e","b"] 。
另一个可行的子序列是 [1,2] ，因为 groups[1] != groups[2] 。
得到答案为 [words[1],words[2]] = ["a","b"] 。
这也是一个可行的答案。
符合题意的最长子序列的长度为 2 。

示例 2：

输入：n = 4, words = ["a","b","c","d"], groups = [1,0,1,1]
输出：["a","b","c"]
解释：一个可行的子序列为 [0,1,2] 因为 groups[0] != groups[1] 且 groups[1] != groups[2] 。
所以一个可行的答案是 [words[0],words[1],words[2]] = ["a","b","c"] 。
另一个可行的子序列为 [0,1,3] 因为 groups[0] != groups[1] 且 groups[1] != groups[3] 。
得到答案为 [words[0],words[1],words[3]] = ["a","b","d"] 。
这也是一个可行的答案。
符合题意的最长子序列的长度为 3 。

提示：

 * 1 <= n == words.length == groups.length <= 100
 * 1 <= words[i].length <= 10
 * 0 <= groups[i] < 2
 * words 中的字符串 互不相同 。
 * words[i] 只包含小写英文字母。

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

```

my_solution = Solution()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


longest-unequal-adjacent-groups-subsequence-ii

Longest Unequal Adjacent Groups Subsequence II

Prompt:
"""
给你一个整数 n 和一个下标从 0 开始的字符串数组 words ，和一个下标从 0 开始的数组 groups ，两个数组长度都是 n 。

两个长度相等字符串的 汉明距离 定义为对应位置字符 不同 的数目。

你需要从下标 [0, 1, ..., n - 1] 中选出一个 最长子序列 ，将这个子序列记作长度为 k 的 [i0, i1, ..., ik - 1] ，它需要满足以下条件：

 * 相邻 下标对应的 groups 值 不同。即，对于所有满足 0 < j + 1 < k 的 j 都有 groups[ij] != groups[ij + 1] 。
 * 对于所有 0 < j + 1 < k 的下标 j ，都满足 words[ij] 和 words[ij + 1] 的长度 相等 ，且两个字符串之间的 汉明距离 为 1 。

请你返回一个字符串数组，它是下标子序列 依次 对应 words 数组中的字符串连接形成的字符串数组。如果有多个答案，返回任意一个。

子序列 指的是从原数组中删掉一些（也可能一个也不删掉）元素，剩余元素不改变相对位置得到的新的数组。

注意：words 中的字符串长度可能 不相等 。

示例 1：

输入：n = 3, words = ["bab","dab","cab"], groups = [1,2,2]
输出：["bab","cab"]
解释：一个可行的子序列是 [0,2] 。
- groups[0] != groups[2]
- words[0].length == words[2].length 且它们之间的汉明距离为 1 。
所以一个可行的答案是 [words[0],words[2]] = ["bab","cab"] 。
另一个可行的子序列是 [0,1] 。
- groups[0] != groups[1]
- words[0].length = words[1].length 且它们之间的汉明距离为 1 。
所以另一个可行的答案是 [words[0],words[1]] = ["bab","dab"] 。
符合题意的最长子序列的长度为 2 。

示例 2：

输入：n = 4, words = ["a","b","c","d"], groups = [1,2,3,4]
输出：["a","b","c","d"]
解释：我们选择子序列 [0,1,2,3] 。
它同时满足两个条件。
所以答案为 [words[0],words[1],words[2],words[3]] = ["a","b","c","d"] 。
它是所有下标子序列里最长且满足所有条件的。
所以它是唯一的答案。

提示：

 * 1 <= n == words.length == groups.length <= 1000
 * 1 <= words[i].length <= 10
 * 1 <= groups[i] <= n
 * words 中的字符串 互不相同 。
 * words[i] 只包含小写英文字母。
"""
class Solution:
    def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:

给你一个整数 n 和一个下标从 0 开始的字符串数组 words ，和一个下标从 0 开始的数组 groups ，两个数组长度都是 n 。

两个长度相等字符串的 汉明距离 定义为对应位置字符 不同 的数目。

你需要从下标 [0, 1, ..., n - 1] 中选出一个 最长子序列 ，将这个子序列记作长度为 k 的 [i0, i1, ..., ik - 1] ，它需要满足以下条件：

 * 相邻 下标对应的 groups 值 不同。即，对于所有满足 0 < j + 1 < k 的 j 都有 groups[ij] != groups[ij + 1] 。
 * 对于所有 0 < j + 1 < k 的下标 j ，都满足 words[ij] 和 words[ij + 1] 的长度 相等 ，且两个字符串之间的 汉明距离 为 1 。

请你返回一个字符串数组，它是下标子序列 依次 对应 words 数组中的字符串连接形成的字符串数组。如果有多个答案，返回任意一个。

子序列 指的是从原数组中删掉一些（也可能一个也不删掉）元素，剩余元素不改变相对位置得到的新的数组。

注意：words 中的字符串长度可能 不相等 。

示例 1：

输入：n = 3, words = ["bab","dab","cab"], groups = [1,2,2]
输出：["bab","cab"]
解释：一个可行的子序列是 [0,2] 。
- groups[0] != groups[2]
- words[0].length == words[2].length 且它们之间的汉明距离为 1 。
所以一个可行的答案是 [words[0],words[2]] = ["bab","cab"] 。
另一个可行的子序列是 [0,1] 。
- groups[0] != groups[1]
- words[0].length = words[1].length 且它们之间的汉明距离为 1 。
所以另一个可行的答案是 [words[0],words[1]] = ["bab","dab"] 。
符合题意的最长子序列的长度为 2 。

示例 2：

输入：n = 4, words = ["a","b","c","d"], groups = [1,2,3,4]
输出：["a","b","c","d"]
解释：我们选择子序列 [0,1,2,3] 。
它同时满足两个条件。
所以答案为 [words[0],words[1],words[2],words[3]] = ["a","b","c","d"] 。
它是所有下标子序列里最长且满足所有条件的。
所以它是唯一的答案。

提示：

 * 1 <= n == words.length == groups.length <= 1000
 * 1 <= words[i].length <= 10
 * 1 <= groups[i] <= n
 * words 中的字符串 互不相同 。
 * words[i] 只包含小写英文字母。

请完成下面的代码来解决上述问题:
```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:
"""
给你一个下标从 0 开始的非负整数数组 nums 和两个整数 l 和 r 。

请你返回 nums 中子多重集合的和在闭区间 [l, r] 之间的 子多重集合的数目 。

由于答案可能很大，请你将答案对 109 + 7 取余后返回。

子多重集合 指的是从数组中选出一些元素构成的 无序 集合，每个元素 x 出现的次数可以是 0, 1, ..., occ[x] 次，其中 occ[x] 是元素 x 在数组中的出现次数。

注意：

 * 如果两个子多重集合中的元素排序后一模一样，那么它们两个是相同的 子多重集合 。
 * 空 集合的和是 0 。

示例 1：

输入：nums = [1,2,2,3], l = 6, r = 6
输出：1
解释：唯一和为 6 的子集合是 {1, 2, 3} 。

示例 2：

输入：nums = [2,1,4,2,7], l = 1, r = 5
输出：7
解释：和在闭区间 [1, 5] 之间的子多重集合为 {1} ，{2} ，{4} ，{2, 2} ，{1, 2} ，{1, 4} 和 {1, 2, 2} 。

示例 3：

输入：nums = [1,2,1,3,5,2], l = 3, r = 5
输出：9
解释：和在闭区间 [3, 5] 之间的子多重集合为 {3} ，{5} ，{1, 2} ，{1, 3} ，{2, 2} ，{2, 3} ，{1, 1, 2} ，{1, 1, 3} 和 {1, 2, 2} 。

提示：

 * 1 <= nums.length <= 2 * 104
 * 0 <= nums[i] <= 2 * 104
 * nums 的和不超过 2 * 104 。
 * 0 <= l <= r <= 2 * 104
"""
class Solution:
    def countSubMultisets(self, nums: List[int], l: int, r: int) -> int:

给你一个下标从 0 开始的非负整数数组 nums 和两个整数 l 和 r 。

请你返回 nums 中子多重集合的和在闭区间 [l, r] 之间的 子多重集合的数目 。

由于答案可能很大，请你将答案对 109 + 7 取余后返回。

子多重集合 指的是从数组中选出一些元素构成的 无序 集合，每个元素 x 出现的次数可以是 0, 1, ..., occ[x] 次，其中 occ[x] 是元素 x 在数组中的出现次数。

注意：

 * 如果两个子多重集合中的元素排序后一模一样，那么它们两个是相同的 子多重集合 。
 * 空 集合的和是 0 。

示例 1：

输入：nums = [1,2,2,3], l = 6, r = 6
输出：1
解释：唯一和为 6 的子集合是 {1, 2, 3} 。

示例 2：

输入：nums = [2,1,4,2,7], l = 1, r = 5
输出：7
解释：和在闭区间 [1, 5] 之间的子多重集合为 {1} ，{2} ，{4} ，{2, 2} ，{1, 2} ，{1, 4} 和 {1, 2, 2} 。

示例 3：

输入：nums = [1,2,1,3,5,2], l = 3, r = 5
输出：9
解释：和在闭区间 [3, 5] 之间的子多重集合为 {3} ，{5} ，{1, 2} ，{1, 3} ，{2, 2} ，{2, 3} ，{1, 1, 2} ，{1, 1, 3} 和 {1, 2, 2} 。

提示：

 * 1 <= nums.length <= 2 * 104
 * 0 <= nums[i] <= 2 * 104
 * nums 的和不超过 2 * 104 。
 * 0 <= l <= r <= 2 * 104

请完成下面的代码来解决上述问题:
```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:
"""
给你两个正整数 n 和 m 。

现定义两个整数 num1 和 num2 ，如下所示：

 * num1：范围 [1, n] 内所有 无法被 m 整除 的整数之和。
 * num2：范围 [1, n] 内所有 能够被 m 整除 的整数之和。

返回整数 num1 - num2 。

示例 1：

输入：n = 10, m = 3
输出：19
解释：在这个示例中：
- 范围 [1, 10] 内无法被 3 整除的整数为 [1,2,4,5,7,8,10] ，num1 = 这些整数之和 = 37 。
- 范围 [1, 10] 内能够被 3 整除的整数为 [3,6,9] ，num2 = 这些整数之和 = 18 。
返回 37 - 18 = 19 作为答案。

示例 2：

输入：n = 5, m = 6
输出：15
解释：在这个示例中：
- 范围 [1, 5] 内无法被 6 整除的整数为 [1,2,3,4,5] ，num1 = 这些整数之和 =  15 。
- 范围 [1, 5] 内能够被 6 整除的整数为 [] ，num2 = 这些整数之和 = 0 。
返回 15 - 0 = 15 作为答案。

示例 3：

输入：n = 5, m = 1
输出：-15
解释：在这个示例中：
- 范围 [1, 5] 内无法被 1 整除的整数为 [] ，num1 = 这些整数之和 = 0 。
- 范围 [1, 5] 内能够被 1 整除的整数为 [1,2,3,4,5] ，num2 = 这些整数之和 = 15 。
返回 0 - 15 = -15 作为答案。

提示：

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

给你两个正整数 n 和 m 。

现定义两个整数 num1 和 num2 ，如下所示：

 * num1：范围 [1, n] 内所有 无法被 m 整除 的整数之和。
 * num2：范围 [1, n] 内所有 能够被 m 整除 的整数之和。

返回整数 num1 - num2 。

示例 1：

输入：n = 10, m = 3
输出：19
解释：在这个示例中：
- 范围 [1, 10] 内无法被 3 整除的整数为 [1,2,4,5,7,8,10] ，num1 = 这些整数之和 = 37 。
- 范围 [1, 10] 内能够被 3 整除的整数为 [3,6,9] ，num2 = 这些整数之和 = 18 。
返回 37 - 18 = 19 作为答案。

示例 2：

输入：n = 5, m = 6
输出：15
解释：在这个示例中：
- 范围 [1, 5] 内无法被 6 整除的整数为 [1,2,3,4,5] ，num1 = 这些整数之和 =  15 。
- 范围 [1, 5] 内能够被 6 整除的整数为 [] ，num2 = 这些整数之和 = 0 。
返回 15 - 0 = 15 作为答案。

示例 3：

输入：n = 5, m = 1
输出：-15
解释：在这个示例中：
- 范围 [1, 5] 内无法被 1 整除的整数为 [] ，num1 = 这些整数之和 = 0 。
- 范围 [1, 5] 内能够被 1 整除的整数为 [1,2,3,4,5] ，num2 = 这些整数之和 = 15 。
返回 0 - 15 = -15 作为答案。

提示：

 * 1 <= n, m <= 1000

请完成下面的代码来解决上述问题:
```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:
"""
你有 n 颗处理器，每颗处理器都有 4 个核心。现有 n * 4 个待执行任务，每个核心只执行 一个 任务。

给你一个下标从 0 开始的整数数组 processorTime ，表示每颗处理器最早空闲时间。另给你一个下标从 0 开始的整数数组 tasks ，表示执行每个任务所需的时间。返回所有任务都执行完毕需要的 最小时间 。

注意：每个核心独立执行任务。

示例 1：

输入：processorTime = [8,10], tasks = [2,2,3,1,8,7,4,5]
输出：16
解释：
最优的方案是将下标为 4, 5, 6, 7 的任务分配给第一颗处理器（最早空闲时间 time = 8），下标为 0, 1, 2, 3 的任务分配给第二颗处理器（最早空闲时间 time = 10）。
第一颗处理器执行完所有任务需要花费的时间 = max(8 + 8, 8 + 7, 8 + 4, 8 + 5) = 16 。
第二颗处理器执行完所有任务需要花费的时间 = max(10 + 2, 10 + 2, 10 + 3, 10 + 1) = 13 。
因此，可以证明执行完所有任务需要花费的最小时间是 16 。

示例 2：

输入：processorTime = [10,20], tasks = [2,3,1,2,5,8,4,3]
输出：23
解释：
最优的方案是将下标为 1, 4, 5, 6 的任务分配给第一颗处理器（最早空闲时间 time = 10），下标为 0, 2, 3, 7 的任务分配给第二颗处理器（最早空闲时间 time = 20）。
第一颗处理器执行完所有任务需要花费的时间 = max(10 + 3, 10 + 5, 10 + 8, 10 + 4) = 18 。
第二颗处理器执行完所有任务需要花费的时间 = max(20 + 2, 20 + 1, 20 + 2, 20 + 3) = 23 。
因此，可以证明执行完所有任务需要花费的最小时间是 23 。

提示：

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

你有 n 颗处理器，每颗处理器都有 4 个核心。现有 n * 4 个待执行任务，每个核心只执行 一个 任务。

给你一个下标从 0 开始的整数数组 processorTime ，表示每颗处理器最早空闲时间。另给你一个下标从 0 开始的整数数组 tasks ，表示执行每个任务所需的时间。返回所有任务都执行完毕需要的 最小时间 。

注意：每个核心独立执行任务。

示例 1：

输入：processorTime = [8,10], tasks = [2,2,3,1,8,7,4,5]
输出：16
解释：
最优的方案是将下标为 4, 5, 6, 7 的任务分配给第一颗处理器（最早空闲时间 time = 8），下标为 0, 1, 2, 3 的任务分配给第二颗处理器（最早空闲时间 time = 10）。
第一颗处理器执行完所有任务需要花费的时间 = max(8 + 8, 8 + 7, 8 + 4, 8 + 5) = 16 。
第二颗处理器执行完所有任务需要花费的时间 = max(10 + 2, 10 + 2, 10 + 3, 10 + 1) = 13 。
因此，可以证明执行完所有任务需要花费的最小时间是 16 。

示例 2：

输入：processorTime = [10,20], tasks = [2,3,1,2,5,8,4,3]
输出：23
解释：
最优的方案是将下标为 1, 4, 5, 6 的任务分配给第一颗处理器（最早空闲时间 time = 10），下标为 0, 2, 3, 7 的任务分配给第二颗处理器（最早空闲时间 time = 20）。
第一颗处理器执行完所有任务需要花费的时间 = max(10 + 3, 10 + 5, 10 + 8, 10 + 4) = 18 。
第二颗处理器执行完所有任务需要花费的时间 = max(20 + 2, 20 + 1, 20 + 2, 20 + 3) = 23 。
因此，可以证明执行完所有任务需要花费的最小时间是 23 。

提示：

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

请完成下面的代码来解决上述问题:
```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:
"""
给你两个下标从 0 开始的二进制字符串 s1 和 s2 ，两个字符串的长度都是 n ，再给你一个正整数 x 。

你可以对字符串 s1 执行以下操作 任意次 ：

 * 选择两个下标 i 和 j ，将 s1[i] 和 s1[j] 都反转，操作的代价为 x 。
 * 选择满足 i < n - 1 的下标 i ，反转 s1[i] 和 s1[i + 1] ，操作的代价为 1 。

请你返回使字符串 s1 和 s2 相等的 最小 操作代价之和，如果无法让二者相等，返回 -1 。

注意 ，反转字符的意思是将 0 变成 1 ，或者 1 变成 0 。

示例 1：

输入：s1 = "1100011000", s2 = "0101001010", x = 2
输出：4
解释：我们可以执行以下操作：
- 选择 i = 3 执行第二个操作。结果字符串是 s1 = "1101111000" 。
- 选择 i = 4 执行第二个操作。结果字符串是 s1 = "1101001000" 。
- 选择 i = 0 和 j = 8 ，执行第一个操作。结果字符串是 s1 = "0101001010" = s2 。
总代价是 1 + 1 + 2 = 4 。这是最小代价和。

示例 2：

输入：s1 = "10110", s2 = "00011", x = 4
输出：-1
解释：无法使两个字符串相等。

提示：

 * n == s1.length == s2.length
 * 1 <= n, x <= 500
 * s1 和 s2 只包含字符 '0' 和 '1' 。
"""
class Solution:
    def minOperations(self, s1: str, s2: str, x: int) -> int:

给你两个下标从 0 开始的二进制字符串 s1 和 s2 ，两个字符串的长度都是 n ，再给你一个正整数 x 。

你可以对字符串 s1 执行以下操作 任意次 ：

 * 选择两个下标 i 和 j ，将 s1[i] 和 s1[j] 都反转，操作的代价为 x 。
 * 选择满足 i < n - 1 的下标 i ，反转 s1[i] 和 s1[i + 1] ，操作的代价为 1 。

请你返回使字符串 s1 和 s2 相等的 最小 操作代价之和，如果无法让二者相等，返回 -1 。

注意 ，反转字符的意思是将 0 变成 1 ，或者 1 变成 0 。

示例 1：

输入：s1 = "1100011000", s2 = "0101001010", x = 2
输出：4
解释：我们可以执行以下操作：
- 选择 i = 3 执行第二个操作。结果字符串是 s1 = "1101111000" 。
- 选择 i = 4 执行第二个操作。结果字符串是 s1 = "1101001000" 。
- 选择 i = 0 和 j = 8 ，执行第一个操作。结果字符串是 s1 = "0101001010" = s2 。
总代价是 1 + 1 + 2 = 4 。这是最小代价和。

示例 2：

输入：s1 = "10110", s2 = "00011", x = 4
输出：-1
解释：无法使两个字符串相等。

提示：

 * n == s1.length == s2.length
 * 1 <= n, x <= 500
 * s1 和 s2 只包含字符 '0' 和 '1' 。

请完成下面的代码来解决上述问题:
```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:
"""
给你一个下标从 0 开始的整数数组 nums 和一个 正 整数 k 。

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

 * 选择两个互不相同的下标 i 和 j ，同时 将 nums[i] 更新为 (nums[i] AND nums[j]) 且将 nums[j] 更新为 (nums[i] OR nums[j]) ，OR 表示按位 或 运算，AND 表示按位 与 运算。

你需要从最终的数组里选择 k 个元素，并计算它们的 平方 之和。

请你返回你可以得到的 最大 平方和。

由于答案可能会很大，将答案对 109 + 7 取余 后返回。

示例 1：

输入：nums = [2,6,5,8], k = 2
输出：261
解释：我们可以对数组执行以下操作：
- 选择 i = 0 和 j = 3 ，同时将 nums[0] 变为 (2 AND 8) = 0 且 nums[3] 变为 (2 OR 8) = 10 ，结果数组为 nums = [0,6,5,10] 。
- 选择 i = 2 和 j = 3 ，同时将 nums[2] 变为 (5 AND 10) = 0 且 nums[3] 变为 (5 OR 10) = 15 ，结果数组为 nums = [0,6,0,15] 。
从最终数组里选择元素 15 和 6 ，平方和为 152 + 62 = 261 。
261 是可以得到的最大结果。

示例 2：

输入：nums = [4,5,4,7], k = 3
输出：90
解释：不需要执行任何操作。
选择元素 7 ，5 和 4 ，平方和为 72 + 52 + 42 = 90 。
90 是可以得到的最大结果。

提示：

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

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

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

 * 选择两个互不相同的下标 i 和 j ，同时 将 nums[i] 更新为 (nums[i] AND nums[j]) 且将 nums[j] 更新为 (nums[i] OR nums[j]) ，OR 表示按位 或 运算，AND 表示按位 与 运算。

你需要从最终的数组里选择 k 个元素，并计算它们的 平方 之和。

请你返回你可以得到的 最大 平方和。

由于答案可能会很大，将答案对 109 + 7 取余 后返回。

示例 1：

输入：nums = [2,6,5,8], k = 2
输出：261
解释：我们可以对数组执行以下操作：
- 选择 i = 0 和 j = 3 ，同时将 nums[0] 变为 (2 AND 8) = 0 且 nums[3] 变为 (2 OR 8) = 10 ，结果数组为 nums = [0,6,5,10] 。
- 选择 i = 2 和 j = 3 ，同时将 nums[2] 变为 (5 AND 10) = 0 且 nums[3] 变为 (5 OR 10) = 15 ，结果数组为 nums = [0,6,0,15] 。
从最终数组里选择元素 15 和 6 ，平方和为 152 + 62 = 261 。
261 是可以得到的最大结果。

示例 2：

输入：nums = [4,5,4,7], k = 3
输出：90
解释：不需要执行任何操作。
选择元素 7 ，5 和 4 ，平方和为 72 + 52 + 42 = 90 。
90 是可以得到的最大结果。

提示：

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

请完成下面的代码来解决上述问题:
```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:
"""
给你一个下标从 0 开始的整数数组 nums 。

请你从所有满足 i < j < k 的下标三元组 (i, j, k) 中，找出并返回下标三元组的最大值。如果所有满足条件的三元组的值都是负数，则返回 0 。

下标三元组 (i, j, k) 的值等于 (nums[i] - nums[j]) * nums[k] 。

示例 1：

输入：nums = [12,6,1,2,7]
输出：77
解释：下标三元组 (0, 2, 4) 的值是 (nums[0] - nums[2]) * nums[4] = 77 。
可以证明不存在值大于 77 的有序下标三元组。

示例 2：

输入：nums = [1,10,3,4,19]
输出：133
解释：下标三元组 (1, 2, 4) 的值是 (nums[1] - nums[2]) * nums[4] = 133 。
可以证明不存在值大于 133 的有序下标三元组。

示例 3：

输入：nums = [1,2,3]
输出：0
解释：唯一的下标三元组 (0, 1, 2) 的值是一个负数，(nums[0] - nums[1]) * nums[2] = -3 。因此，答案是 0 。

提示：

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

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

请你从所有满足 i < j < k 的下标三元组 (i, j, k) 中，找出并返回下标三元组的最大值。如果所有满足条件的三元组的值都是负数，则返回 0 。

下标三元组 (i, j, k) 的值等于 (nums[i] - nums[j]) * nums[k] 。

示例 1：

输入：nums = [12,6,1,2,7]
输出：77
解释：下标三元组 (0, 2, 4) 的值是 (nums[0] - nums[2]) * nums[4] = 77 。
可以证明不存在值大于 77 的有序下标三元组。

示例 2：

输入：nums = [1,10,3,4,19]
输出：133
解释：下标三元组 (1, 2, 4) 的值是 (nums[1] - nums[2]) * nums[4] = 133 。
可以证明不存在值大于 133 的有序下标三元组。

示例 3：

输入：nums = [1,2,3]
输出：0
解释：唯一的下标三元组 (0, 1, 2) 的值是一个负数，(nums[0] - nums[1]) * nums[2] = -3 。因此，答案是 0 。

提示：

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

请完成下面的代码来解决上述问题:
```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:
"""
给你一个下标从 0 开始的整数数组 nums 。

请你从所有满足 i < j < k 的下标三元组 (i, j, k) 中，找出并返回下标三元组的最大值。如果所有满足条件的三元组的值都是负数，则返回 0 。

下标三元组 (i, j, k) 的值等于 (nums[i] - nums[j]) * nums[k] 。

示例 1：

输入：nums = [12,6,1,2,7]
输出：77
解释：下标三元组 (0, 2, 4) 的值是 (nums[0] - nums[2]) * nums[4] = 77 。
可以证明不存在值大于 77 的有序下标三元组。

示例 2：

输入：nums = [1,10,3,4,19]
输出：133
解释：下标三元组 (1, 2, 4) 的值是 (nums[1] - nums[2]) * nums[4] = 133 。
可以证明不存在值大于 133 的有序下标三元组。

示例 3：

输入：nums = [1,2,3]
输出：0
解释：唯一的下标三元组 (0, 1, 2) 的值是一个负数，(nums[0] - nums[1]) * nums[2] = -3 。因此，答案是 0 。

提示：

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

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

请你从所有满足 i < j < k 的下标三元组 (i, j, k) 中，找出并返回下标三元组的最大值。如果所有满足条件的三元组的值都是负数，则返回 0 。

下标三元组 (i, j, k) 的值等于 (nums[i] - nums[j]) * nums[k] 。

示例 1：

输入：nums = [12,6,1,2,7]
输出：77
解释：下标三元组 (0, 2, 4) 的值是 (nums[0] - nums[2]) * nums[4] = 77 。
可以证明不存在值大于 77 的有序下标三元组。

示例 2：

输入：nums = [1,10,3,4,19]
输出：133
解释：下标三元组 (1, 2, 4) 的值是 (nums[1] - nums[2]) * nums[4] = 133 。
可以证明不存在值大于 133 的有序下标三元组。

示例 3：

输入：nums = [1,2,3]
输出：0
解释：唯一的下标三元组 (0, 1, 2) 的值是一个负数，(nums[0] - nums[1]) * nums[2] = -3 。因此，答案是 0 。

提示：

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

请完成下面的代码来解决上述问题:
```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