palindrome-rearrangement-queries

Palindrome Rearrangement Queries

Prompt:
"""
给你一个长度为 偶数n，下标从 0开始的字符串s。
同时给你一个下标从 0开始的二维整数数组queries，其中queries[i] = [ai, bi, ci, di]。
对于每个查询i，你需要执行以下操作：

将下标在范围0 <= ai <= bi < n / 2内的子字符串s[ai:bi]中的字符重新排列。
将下标在范围 n / 2 <= ci <= di < n内的 子字符串s[ci:di]中的字符重新排列。

对于每个查询，你的任务是判断执行操作后能否让 s变成一个 回文串 。
每个查询与其他查询都是 独立的。
请你返回一个下标从 0开始的数组answer，如果第i个查询执行操作后，可以将s变为一个回文串，那么answer[i] =true，否则为false。

子字符串指的是一个字符串中一段连续的字符序列。
s[x:y]表示 s中从下标 x到 y且两个端点 都包含的子字符串。

示例 1：

输入：s = "abcabc", queries = [[1,1,3,5],[0,2,5,5]]
输出：[true,true]
解释：这个例子中，有 2 个查询：
第一个查询：
- a0 = 1, b0 = 1, c0 = 3, d0 = 5
- 你可以重新排列 s[1:1] => abcabc 和 s[3:5] => abcabc。
- 为了让 s 变为回文串，s[3:5] 可以重新排列得到 => abccba 。
- 现在 s 是一个回文串。所以 answer[0] = true 。
第二个查询：
- a1 = 0, b1 = 2, c1 = 5, d1 = 5.
- 你可以重新排列 s[0:2] => abcabc 和 s[5:5] => abcabc。
- 为了让 s 变为回文串，s[0:2] 可以重新排列得到 => cbaabc 。
- 现在 s 是一个回文串，所以 answer[1] = true 。

示例 2：

输入：s = "abbcdecbba", queries = [[0,2,7,9]]
输出：[false]
解释：这个示例中，只有一个查询。
a0 = 0, b0 = 2, c0 = 7, d0 = 9.
你可以重新排列 s[0:2] => abbcdecbba 和 s[7:9] => abbcdecbba。
无法通过重新排列这些子字符串使 s 变为一个回文串，因为 s[3:6] 不是一个回文串。
所以 answer[0] = false 。
示例 3：

输入：s = "acbcab", queries = [[1,2,4,5]]
输出：[true]
解释：这个示例中，只有一个查询。
a0 = 1, b0 = 2, c0 = 4, d0 = 5.
你可以重新排列 s[1:2] => acbcab 和 s[4:5] => acbcab。
为了让 s 变为回文串，s[1:2] 可以重新排列得到 => abccab。
然后 s[4:5] 重新排列得到 abccba。
现在 s 是一个回文串，所以 answer[0] = true 。

提示：

2 <= n == s.length <= 105
1 <= queries.length <= 105
queries[i].length == 4
ai == queries[i][0], bi == queries[i][1]
ci == queries[i][2], di == queries[i][3]
0 <= ai <= bi < n / 2
n / 2 <= ci <= di < n
n是一个偶数。
s 只包含小写英文字母。
"""
class Solution:
    def canMakePalindromeQueries(self, s: str, queries: List[List[int]]) -> List[bool]:

给你一个长度为 偶数n，下标从 0开始的字符串s。
同时给你一个下标从 0开始的二维整数数组queries，其中queries[i] = [ai, bi, ci, di]。
对于每个查询i，你需要执行以下操作：

将下标在范围0 <= ai <= bi < n / 2内的子字符串s[ai:bi]中的字符重新排列。
将下标在范围 n / 2 <= ci <= di < n内的 子字符串s[ci:di]中的字符重新排列。

对于每个查询，你的任务是判断执行操作后能否让 s变成一个 回文串 。
每个查询与其他查询都是 独立的。
请你返回一个下标从 0开始的数组answer，如果第i个查询执行操作后，可以将s变为一个回文串，那么answer[i] =true，否则为false。

子字符串指的是一个字符串中一段连续的字符序列。
s[x:y]表示 s中从下标 x到 y且两个端点 都包含的子字符串。

示例 1：

输入：s = "abcabc", queries = [[1,1,3,5],[0,2,5,5]]
输出：[true,true]
解释：这个例子中，有 2 个查询：
第一个查询：
- a0 = 1, b0 = 1, c0 = 3, d0 = 5
- 你可以重新排列 s[1:1] => abcabc 和 s[3:5] => abcabc。
- 为了让 s 变为回文串，s[3:5] 可以重新排列得到 => abccba 。
- 现在 s 是一个回文串。所以 answer[0] = true 。
第二个查询：
- a1 = 0, b1 = 2, c1 = 5, d1 = 5.
- 你可以重新排列 s[0:2] => abcabc 和 s[5:5] => abcabc。
- 为了让 s 变为回文串，s[0:2] 可以重新排列得到 => cbaabc 。
- 现在 s 是一个回文串，所以 answer[1] = true 。

示例 2：

输入：s = "abbcdecbba", queries = [[0,2,7,9]]
输出：[false]
解释：这个示例中，只有一个查询。
a0 = 0, b0 = 2, c0 = 7, d0 = 9.
你可以重新排列 s[0:2] => abbcdecbba 和 s[7:9] => abbcdecbba。
无法通过重新排列这些子字符串使 s 变为一个回文串，因为 s[3:6] 不是一个回文串。
所以 answer[0] = false 。
示例 3：

输入：s = "acbcab", queries = [[1,2,4,5]]
输出：[true]
解释：这个示例中，只有一个查询。
a0 = 1, b0 = 2, c0 = 4, d0 = 5.
你可以重新排列 s[1:2] => acbcab 和 s[4:5] => acbcab。
为了让 s 变为回文串，s[1:2] 可以重新排列得到 => abccab。
然后 s[4:5] 重新排列得到 abccba。
现在 s 是一个回文串，所以 answer[0] = true 。

提示：

2 <= n == s.length <= 105
1 <= queries.length <= 105
queries[i].length == 4
ai == queries[i][0], bi == queries[i][1]
ci == queries[i][2], di == queries[i][3]
0 <= ai <= bi < n / 2
n / 2 <= ci <= di < n
n是一个偶数。
s 只包含小写英文字母。

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

```

my_solution = Solution()

test_input = { "s": "abcabc", "queries": [[1,1,3,5],[0,2,5,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "abbcdecbba", "queries": [[0,2,7,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "acbcab", "queries": [[1,2,4,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "bcdbdc", "queries": [[1,2,3,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "bb", "queries": [[0,0,1,1]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "eoquueqo", "queries": [[3,3,6,6]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "dd", "queries": [[0,0,1,1]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "ceddceddcc", "queries": [[0,1,6,8]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "bdbd", "queries": [[0,0,2,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "eeee", "queries": [[0,1,2,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "deebdeeddb", "queries": [[1,2,5,7]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "xwaswsxwaw", "queries": [[1,3,5,6]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "askloakosala", "queries": [[2,4,7,10]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "bbccbb", "queries": [[0,1,4,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "djaypzjpyzad", "queries": [[0,3,7,8]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "ajvnbnznjnzbva", "queries": [[5,6,10,11]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "vbeptwzvtwpzbe", "queries": [[3,6,10,11]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "cababc", "queries": [[1,2,3,4]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "cbbbbc", "queries": [[1,1,5,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "qupzexxhqxpzhxeu", "queries": [[2,4,8,12]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "cdbdbc", "queries": [[1,2,3,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "odaxusaweuasuoeudxwa", "queries": [[0,5,10,14]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "ujfscqolkwjucoswlkfq", "queries": [[1,9,17,18]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "ceacea", "queries": [[0,2,3,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "bnjzcgmnecxxbmnjngxzecxc", "queries": [[8,9,19,22]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "daeaed", "queries": [[0,2,3,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "ddaadd", "queries": [[0,2,3,4]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "ddedde", "queries": [[0,2,4,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "pmzwetzhzursuhmeswpzrztz", "queries": [[4,6,16,17]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "qcryjkdzmqyoojzrckymdqyq", "queries": [[2,8,21,22]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "qdltkndnclarncadtqnlldkr", "queries": [[3,4,15,16]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "ecbbce", "queries": [[0,1,3,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "eczecz", "queries": [[0,0,3,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "etuouqokbalafokfbuqaaoetlu", "queries": [[3,11,21,23]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "mpepem", "queries": [[0,2,3,4]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "nbpechkpmudbsenphdmsbbupck", "queries": [[6,7,18,19]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "bccacacb", "queries": [[3,3,4,7]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "stgjtzqwgkuadjgqugkwdtzast", "queries": [[5,10,13,23]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "qiyikbayvhkcgxyaqckgxkhivbyi", "queries": [[5,12,17,24]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "ceedceed", "queries": [[0,1,4,7]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "rcguwczbjhjhgqrggqcbwjzhjuch", "queries": [[5,7,16,20]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "ckwbnmqmtzbixrrkixbtbqzmnwmc", "queries": [[1,9,15,24]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True]

test_input = { "s": "riirxzxuqpspoiixpirsoxrzpiuq", "queries": [[1,6,14,21]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "geettndnusqufidtqdfgtsieenundu", "queries": [[6,8,19,23]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False]

test_input = { "s": "bb", "queries": [[0,0,1,1],[0,0,1,1]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "cc", "queries": [[0,0,1,1],[0,0,1,1]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "dd", "queries": [[0,0,1,1],[0,0,1,1]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "ee", "queries": [[0,0,1,1],[0,0,1,1]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "aeae", "queries": [[1,1,2,3],[1,1,3,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,False]

test_input = { "s": "eaae", "queries": [[0,1,3,3],[0,0,2,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "eded", "queries": [[0,1,2,3],[1,1,2,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "lrlr", "queries": [[0,1,2,3],[0,0,2,2]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,False]

test_input = { "s": "dbaabd", "queries": [[0,1,5,5],[1,2,4,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "dcbcbd", "queries": [[0,1,4,4],[0,2,3,4]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,True]

test_input = { "s": "hykkyh", "queries": [[0,0,3,4],[1,2,3,4]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "lvrvrl", "queries": [[2,2,4,5],[0,2,3,4]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,True]

test_input = { "s": "adceaecd", "queries": [[3,3,5,5],[0,1,4,6]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,True]

test_input = { "s": "baadadba", "queries": [[1,2,4,5],[0,2,4,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,True]

test_input = { "s": "bceaabec", "queries": [[1,3,4,7],[0,2,6,6]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "ifchcifh", "queries": [[1,2,5,6],[1,1,4,6]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "adeeeeeaed", "queries": [[2,4,7,9],[3,4,8,8]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,False]

test_input = { "s": "aedbdbddea", "queries": [[4,4,7,8],[2,2,8,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "caeaaaaaec", "queries": [[0,2,5,8],[0,0,5,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True]

test_input = { "s": "dbaccccdba", "queries": [[4,4,6,7],[2,3,8,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "deabadabea", "queries": [[0,3,7,9],[0,2,5,7]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,True]

test_input = { "s": "eddeededee", "queries": [[0,3,6,9],[0,0,6,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "eedbbedebb", "queries": [[2,2,6,7],[2,2,5,6]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "gvtkakgvat", "queries": [[1,2,7,7],[2,3,7,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "bzvvicviczbv", "queries": [[1,2,7,8],[1,4,7,8]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "ljccjajcljac", "queries": [[2,4,6,10],[3,5,7,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "rxvzvezvrvxe", "queries": [[1,4,8,10],[3,3,10,11]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "amgpelwpmlaewg", "queries": [[3,4,7,9],[0,6,7,10]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,True]

test_input = { "s": "leubdglmbglleudm", "queries": [[1,3,9,14],[2,6,13,14]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "ooxuznriuzrooixn", "queries": [[1,3,10,12],[1,4,9,13]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "nlaonaphinpnalohai", "queries": [[2,5,13,13],[2,7,9,14]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "rujokutobuttlysjusrtltuobkoytu", "queries": [[5,6,18,23],[10,13,15,26]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False]

test_input = { "s": "bb", "queries": [[0,0,1,1],[0,0,1,1],[0,0,1,1]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,True]

test_input = { "s": "cc", "queries": [[0,0,1,1],[0,0,1,1],[0,0,1,1]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,True]

test_input = { "s": "dbdb", "queries": [[0,0,2,2],[1,1,3,3],[0,1,2,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,True]

test_input = { "s": "ebbe", "queries": [[0,1,3,3],[1,1,2,2],[0,0,2,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,True]

test_input = { "s": "acacaa", "queries": [[0,1,5,5],[1,1,4,4],[1,2,3,4]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,True]

test_input = { "s": "bbaabb", "queries": [[0,1,4,5],[0,2,3,5],[2,2,5,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,True]

test_input = { "s": "bbebbe", "queries": [[0,1,3,5],[2,2,4,5],[0,1,5,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,False,False]

test_input = { "s": "ddaadd", "queries": [[1,1,4,4],[0,0,4,4],[0,2,3,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,True]

test_input = { "s": "nlhhln", "queries": [[2,2,4,5],[1,2,5,5],[2,2,3,3]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,True]

test_input = { "s": "zbebez", "queries": [[0,2,5,5],[1,1,3,5],[0,2,4,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,True]

test_input = { "s": "cbcbbcbc", "queries": [[0,2,7,7],[1,2,4,7],[0,2,4,5]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,True]

test_input = { "s": "deceecde", "queries": [[3,3,6,7],[1,2,4,5],[2,3,7,7]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,False,False]

test_input = { "s": "fydyfyyd", "queries": [[0,2,4,6],[1,3,4,7],[2,3,6,7]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [True,True,False]

test_input = { "s": "dccabcdbca", "queries": [[1,3,5,8],[2,4,7,7],[0,2,6,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "eacbdeacbd", "queries": [[4,4,8,9],[3,4,7,9],[0,0,6,8]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "eddaaedada", "queries": [[0,1,7,8],[0,1,7,8],[0,3,7,9]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "vvsbgsvgbv", "queries": [[0,1,6,9],[2,3,8,9],[0,0,6,7]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "sukesivksseuiv", "queries": [[2,3,11,13],[5,5,7,13],[2,5,8,13]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,True,False]

test_input = { "s": "pbcjpsfxwtbcfjwpsptx", "queries": [[0,4,13,13],[5,5,15,18],[2,3,13,18]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "natvhtruvwyutyvvnarhwt", "queries": [[5,7,14,21],[0,8,11,19],[2,8,11,14]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "yjsjywxbriejyxieysrwbj", "queries": [[4,5,15,19],[1,9,12,17],[3,6,12,18]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "ellaghdbmazdallhmegabddz", "queries": [[4,6,13,19],[4,11,17,17],[7,10,13,16]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "wcfnhuaulqxbuuxafcwhnbql", "queries": [[5,11,13,18],[7,8,18,21],[3,6,21,23]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]

test_input = { "s": "qyioinjmvpgpropimvqiygrnjp", "queries": [[1,4,15,25],[1,8,19,22],[4,9,18,23]] }
assert my_solution.canMakePalindromeQueries(**test_input) == [False,False,False]


minimum-number-game

Minimum Number Game

Prompt:
"""
你有一个下标从 0 开始、长度为 偶数 的整数数组 nums ，同时还有一个空数组 arr 。Alice 和 Bob 决定玩一个游戏，游戏中每一轮 Alice 和 Bob 都会各自执行一次操作。游戏规则如下：

每一轮，Alice 先从 nums 中移除一个 最小 元素，然后 Bob 执行同样的操作。
接着，Bob 会将移除的元素添加到数组 arr 中，然后 Alice 也执行同样的操作。
游戏持续进行，直到 nums 变为空。

返回结果数组 arr 。

示例 1：

输入：nums = [5,4,2,3]
输出：[3,2,5,4]
解释：第一轮，Alice 先移除 2 ，然后 Bob 移除 3 。然后 Bob 先将 3 添加到 arr 中，接着 Alice 再将 2 添加到 arr 中。于是 arr = [3,2] 。
第二轮开始时，nums = [5,4] 。Alice 先移除 4 ，然后 Bob 移除 5 。接着他们都将元素添加到 arr 中，arr 变为 [3,2,5,4] 。

示例 2：

输入：nums = [2,5]
输出：[5,2]
解释：第一轮，Alice 先移除 2 ，然后 Bob 移除 5 。然后 Bob 先将 5 添加到 arr 中，接着 Alice 再将 2 添加到 arr 中。于是 arr = [5,2] 。

提示：

1 <= nums.length <= 100
1 <= nums[i] <= 100
nums.length % 2 == 0
"""
class Solution:
    def numberGame(self, nums: List[int]) -> List[int]:

你有一个下标从 0 开始、长度为 偶数 的整数数组 nums ，同时还有一个空数组 arr 。Alice 和 Bob 决定玩一个游戏，游戏中每一轮 Alice 和 Bob 都会各自执行一次操作。游戏规则如下：

每一轮，Alice 先从 nums 中移除一个 最小 元素，然后 Bob 执行同样的操作。
接着，Bob 会将移除的元素添加到数组 arr 中，然后 Alice 也执行同样的操作。
游戏持续进行，直到 nums 变为空。

返回结果数组 arr 。

示例 1：

输入：nums = [5,4,2,3]
输出：[3,2,5,4]
解释：第一轮，Alice 先移除 2 ，然后 Bob 移除 3 。然后 Bob 先将 3 添加到 arr 中，接着 Alice 再将 2 添加到 arr 中。于是 arr = [3,2] 。
第二轮开始时，nums = [5,4] 。Alice 先移除 4 ，然后 Bob 移除 5 。接着他们都将元素添加到 arr 中，arr 变为 [3,2,5,4] 。

示例 2：

输入：nums = [2,5]
输出：[5,2]
解释：第一轮，Alice 先移除 2 ，然后 Bob 移除 5 。然后 Bob 先将 5 添加到 arr 中，接着 Alice 再将 2 添加到 arr 中。于是 arr = [5,2] 。

提示：

1 <= nums.length <= 100
1 <= nums[i] <= 100
nums.length % 2 == 0

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

```

my_solution = Solution()

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

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

test_input = { "nums": [4,4,3,8] }
assert my_solution.numberGame(**test_input) == [4,3,8,4]

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

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

test_input = { "nums": [18,26,37,46,13,33,39,1,37,16] }
assert my_solution.numberGame(**test_input) == [13,1,18,16,33,26,37,37,46,39]

test_input = { "nums": [17,2,4,11,14,18] }
assert my_solution.numberGame(**test_input) == [4,2,14,11,18,17]

test_input = { "nums": [20,30,12,3,11,17,32,12] }
assert my_solution.numberGame(**test_input) == [11,3,12,12,20,17,32,30]

test_input = { "nums": [9,32,6,11,11,39,18,29,44,29] }
assert my_solution.numberGame(**test_input) == [9,6,11,11,29,18,32,29,44,39]

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

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

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

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

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

test_input = { "nums": [13,12,18,11,15,28,26,2] }
assert my_solution.numberGame(**test_input) == [11,2,13,12,18,15,28,26]

test_input = { "nums": [14,30,29,3,23,21,26,23] }
assert my_solution.numberGame(**test_input) == [14,3,23,21,26,23,30,29]

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

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

test_input = { "nums": [12,1,28,23,2,31,11,26] }
assert my_solution.numberGame(**test_input) == [2,1,12,11,26,23,31,28]

test_input = { "nums": [21,11,37,1,40,50,49,45,28,47] }
assert my_solution.numberGame(**test_input) == [11,1,28,21,40,37,47,45,50,49]

test_input = { "nums": [25,22,31,7,30,9,9,18] }
assert my_solution.numberGame(**test_input) == [9,7,18,9,25,22,31,30]

test_input = { "nums": [2,4,10,9,16,9] }
assert my_solution.numberGame(**test_input) == [4,2,9,9,16,10]

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

test_input = { "nums": [6,44,37,6,28,44,30,36,25,24] }
assert my_solution.numberGame(**test_input) == [6,6,25,24,30,28,37,36,44,44]

test_input = { "nums": [17,10,6,14,10,18] }
assert my_solution.numberGame(**test_input) == [10,6,14,10,18,17]

test_input = { "nums": [40,24,23,29,37,26,39,34,39,23] }
assert my_solution.numberGame(**test_input) == [23,23,26,24,34,29,39,37,40,39]

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

test_input = { "nums": [33,5,31,43,48,18,31,11,19,8] }
assert my_solution.numberGame(**test_input) == [8,5,18,11,31,19,33,31,48,43]

test_input = { "nums": [37,46,42,19,10,8,43,10,40,13] }
assert my_solution.numberGame(**test_input) == [10,8,13,10,37,19,42,40,46,43]

test_input = { "nums": [2,19,8,22,1,27,29,7] }
assert my_solution.numberGame(**test_input) == [2,1,8,7,22,19,29,27]

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

test_input = { "nums": [1,4,7,14,8,14] }
assert my_solution.numberGame(**test_input) == [4,1,8,7,14,14]

test_input = { "nums": [28,47,36,34,19,7,40,46,33,43] }
assert my_solution.numberGame(**test_input) == [19,7,33,28,36,34,43,40,47,46]

test_input = { "nums": [29,41,20,22,16,27,22,44,10,47] }
assert my_solution.numberGame(**test_input) == [16,10,22,20,27,22,41,29,47,44]

test_input = { "nums": [14,6,40,19,47,46,34,27,28,10] }
assert my_solution.numberGame(**test_input) == [10,6,19,14,28,27,40,34,47,46]

test_input = { "nums": [42,43,50,43,36,26,16,12,3,2] }
assert my_solution.numberGame(**test_input) == [3,2,16,12,36,26,43,42,50,43]

test_input = { "nums": [1,7,24,24,23,32,28,2] }
assert my_solution.numberGame(**test_input) == [2,1,23,7,24,24,32,28]

test_input = { "nums": [20,19,16,16,19,29,21,5] }
assert my_solution.numberGame(**test_input) == [16,5,19,16,20,19,29,21]

test_input = { "nums": [20,9,29,29,17,39,27,44,1,8] }
assert my_solution.numberGame(**test_input) == [8,1,17,9,27,20,29,29,44,39]

test_input = { "nums": [14,11,12,18,9,15] }
assert my_solution.numberGame(**test_input) == [11,9,14,12,18,15]

test_input = { "nums": [17,22,2,35,15,19,25,5,33,44] }
assert my_solution.numberGame(**test_input) == [5,2,17,15,22,19,33,25,44,35]

test_input = { "nums": [22,3,26,15,1,5,14,28] }
assert my_solution.numberGame(**test_input) == [3,1,14,5,22,15,28,26]

test_input = { "nums": [5,24,3,2,17,9,2,4] }
assert my_solution.numberGame(**test_input) == [2,2,4,3,9,5,24,17]

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

test_input = { "nums": [1,33,29,21,25,14,26,35,34,30] }
assert my_solution.numberGame(**test_input) == [14,1,25,21,29,26,33,30,35,34]

test_input = { "nums": [50,25,42,41,16,23,47,31,23,16] }
assert my_solution.numberGame(**test_input) == [16,16,23,23,31,25,42,41,50,47]

test_input = { "nums": [31,31,31,12,24,17,11,3,33,13] }
assert my_solution.numberGame(**test_input) == [11,3,13,12,24,17,31,31,33,31]

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

test_input = { "nums": [8,2,8,6] }
assert my_solution.numberGame(**test_input) == [6,2,8,8]

test_input = { "nums": [4,15,16,2,12,7] }
assert my_solution.numberGame(**test_input) == [4,2,12,7,16,15]

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

test_input = { "nums": [17,13,7,12,19,15,6,22] }
assert my_solution.numberGame(**test_input) == [7,6,13,12,17,15,22,19]

test_input = { "nums": [2,15,12,16,12,13] }
assert my_solution.numberGame(**test_input) == [12,2,13,12,16,15]

test_input = { "nums": [3,15,18,16,6,7] }
assert my_solution.numberGame(**test_input) == [6,3,15,7,18,16]

test_input = { "nums": [4,7,11,6,11,8] }
assert my_solution.numberGame(**test_input) == [6,4,8,7,11,11]

test_input = { "nums": [1,7,24,23,16,21,9,11] }
assert my_solution.numberGame(**test_input) == [7,1,11,9,21,16,24,23]

test_input = { "nums": [6,3,10,16,15,6] }
assert my_solution.numberGame(**test_input) == [6,3,10,6,16,15]

test_input = { "nums": [17,9,1,29,30,5,31,26] }
assert my_solution.numberGame(**test_input) == [5,1,17,9,29,26,31,30]

test_input = { "nums": [3,6,4,14,9,15] }
assert my_solution.numberGame(**test_input) == [4,3,9,6,15,14]

test_input = { "nums": [37,38,24,15,12,1,37,19,38,11] }
assert my_solution.numberGame(**test_input) == [11,1,15,12,24,19,37,37,38,38]

test_input = { "nums": [17,3,8,12,6,9] }
assert my_solution.numberGame(**test_input) == [6,3,9,8,17,12]

test_input = { "nums": [32,23,27,32,24,26,24,27] }
assert my_solution.numberGame(**test_input) == [24,23,26,24,27,27,32,32]

test_input = { "nums": [15,16,26,6,5,9,22,14] }
assert my_solution.numberGame(**test_input) == [6,5,14,9,16,15,26,22]

test_input = { "nums": [14,21,13,10,2,16,14,30] }
assert my_solution.numberGame(**test_input) == [10,2,14,13,16,14,30,21]

test_input = { "nums": [1,6,30,1,13,25,18,1] }
assert my_solution.numberGame(**test_input) == [1,1,6,1,18,13,30,25]

test_input = { "nums": [32,12,17,32,11,25,22,18,10,1] }
assert my_solution.numberGame(**test_input) == [10,1,12,11,18,17,25,22,32,32]

test_input = { "nums": [2,8,5,6] }
assert my_solution.numberGame(**test_input) == [5,2,8,6]

test_input = { "nums": [27,3,10,25,10,7,15,16] }
assert my_solution.numberGame(**test_input) == [7,3,10,10,16,15,27,25]

test_input = { "nums": [5,18,19,25,13,21,16,7] }
assert my_solution.numberGame(**test_input) == [7,5,16,13,19,18,25,21]

test_input = { "nums": [8,6,6,8] }
assert my_solution.numberGame(**test_input) == [6,6,8,8]

test_input = { "nums": [23,15,39,9,19,10,6,9,33,28] }
assert my_solution.numberGame(**test_input) == [9,6,10,9,19,15,28,23,39,33]

test_input = { "nums": [16,42,47,16,31,39,8,26,50,33] }
assert my_solution.numberGame(**test_input) == [16,8,26,16,33,31,42,39,50,47]

test_input = { "nums": [4,31,9,2,4,28,28,12] }
assert my_solution.numberGame(**test_input) == [4,2,9,4,28,12,31,28]

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

test_input = { "nums": [44,2,23,3,7,2,36,33,7,21] }
assert my_solution.numberGame(**test_input) == [2,2,7,3,21,7,33,23,44,36]

test_input = { "nums": [19,9,4,7,29,22,50,28,2,40] }
assert my_solution.numberGame(**test_input) == [4,2,9,7,22,19,29,28,50,40]

test_input = { "nums": [4,5,5,5] }
assert my_solution.numberGame(**test_input) == [5,4,5,5]

test_input = { "nums": [42,6,44,47,11,6,30,38,41,43] }
assert my_solution.numberGame(**test_input) == [6,6,30,11,41,38,43,42,47,44]

test_input = { "nums": [28,4,47,1,7,35,10,10,5,8] }
assert my_solution.numberGame(**test_input) == [4,1,7,5,10,8,28,10,47,35]

test_input = { "nums": [12,20,14,46,22,1,42,50,47,47] }
assert my_solution.numberGame(**test_input) == [12,1,20,14,42,22,47,46,50,47]

test_input = { "nums": [37,13,1,38,28,46,18,22,12,7] }
assert my_solution.numberGame(**test_input) == [7,1,13,12,22,18,37,28,46,38]

test_input = { "nums": [36,41,5,33,5,30,33,31,6,45] }
assert my_solution.numberGame(**test_input) == [5,5,30,6,33,31,36,33,45,41]

test_input = { "nums": [13,50,42,24,47,41,8,26,34,3] }
assert my_solution.numberGame(**test_input) == [8,3,24,13,34,26,42,41,50,47]

test_input = { "nums": [24,39,26,46,47,9,33,6,33,40] }
assert my_solution.numberGame(**test_input) == [9,6,26,24,33,33,40,39,47,46]

test_input = { "nums": [14,13,17,14,12,15,6,32] }
assert my_solution.numberGame(**test_input) == [12,6,14,13,15,14,32,17]

test_input = { "nums": [46,50,35,11,14,44,17,45,23,34] }
assert my_solution.numberGame(**test_input) == [14,11,23,17,35,34,45,44,50,46]

test_input = { "nums": [8,27,19,7,10,12,14,50,45,14] }
assert my_solution.numberGame(**test_input) == [8,7,12,10,14,14,27,19,50,45]

test_input = { "nums": [9,8,5,7,10,9] }
assert my_solution.numberGame(**test_input) == [7,5,9,8,10,9]

test_input = { "nums": [5,5,3,7] }
assert my_solution.numberGame(**test_input) == [5,3,7,5]

test_input = { "nums": [26,21,7,13,3,10,9,15] }
assert my_solution.numberGame(**test_input) == [7,3,10,9,15,13,26,21]

test_input = { "nums": [8,5,8,3] }
assert my_solution.numberGame(**test_input) == [5,3,8,8]

test_input = { "nums": [18,1,16,18,13,3] }
assert my_solution.numberGame(**test_input) == [3,1,16,13,18,18]

test_input = { "nums": [25,2,17,26,17,20,19,24] }
assert my_solution.numberGame(**test_input) == [17,2,19,17,24,20,26,25]

test_input = { "nums": [24,1,18,25,29,17,9,3] }
assert my_solution.numberGame(**test_input) == [3,1,17,9,24,18,29,25]

test_input = { "nums": [23,17,18,18,18,30,8,19] }
assert my_solution.numberGame(**test_input) == [17,8,18,18,19,18,30,23]

test_input = { "nums": [12,13,13,18,5,16] }
assert my_solution.numberGame(**test_input) == [12,5,13,13,18,16]

test_input = { "nums": [19,4,11,7,24,12,24,14] }
assert my_solution.numberGame(**test_input) == [7,4,12,11,19,14,24,24]

test_input = { "nums": [28,11,11,29,18,2,6,32] }
assert my_solution.numberGame(**test_input) == [6,2,11,11,28,18,32,29]

test_input = { "nums": [12,17,3,31,15,18,18,2] }
assert my_solution.numberGame(**test_input) == [3,2,15,12,18,17,31,18]

test_input = { "nums": [24,6,21,30,29,8,23,18] }
assert my_solution.numberGame(**test_input) == [8,6,21,18,24,23,30,29]


maximum-square-area-by-removing-fences-from-a-field

Maximum Square Area by Removing Fences From a Field

Prompt:
"""
有一个大型的 (m - 1) x (n - 1) 矩形田地，其两个对角分别是 (1, 1) 和 (m, n) ，田地内部有一些水平栅栏和垂直栅栏，分别由数组 hFences 和 vFences 给出。
水平栅栏为坐标 (hFences[i], 1) 到 (hFences[i], n)，垂直栅栏为坐标 (1, vFences[i]) 到 (m, vFences[i]) 。
返回通过 移除 一些栅栏（可能不移除）所能形成的最大面积的 正方形 田地的面积，或者如果无法形成正方形田地则返回 -1。
由于答案可能很大，所以请返回结果对 109 + 7 取余 后的值。
注意：田地外围两个水平栅栏（坐标 (1, 1) 到 (1, n) 和坐标 (m, 1) 到 (m, n) ）以及两个垂直栅栏（坐标 (1, 1) 到 (m, 1) 和坐标 (1, n) 到 (m, n) ）所包围。这些栅栏 不能 被移除。

示例 1：

输入：m = 4, n = 3, hFences = [2,3], vFences = [2]
输出：4
解释：移除位于 2 的水平栅栏和位于 2 的垂直栅栏将得到一个面积为 4 的正方形田地。

示例 2：

输入：m = 6, n = 7, hFences = [2], vFences = [4]
输出：-1
解释：可以证明无法通过移除栅栏形成正方形田地。

提示：

3 <= m, n <= 109
1 <= hFences.length, vFences.length <= 600
1 < hFences[i] < m
1 < vFences[i] < n
hFences 和 vFences 中的元素是唯一的。
"""
class Solution:
    def maximizeSquareArea(self, m: int, n: int, hFences: List[int], vFences: List[int]) -> int:

有一个大型的 (m - 1) x (n - 1) 矩形田地，其两个对角分别是 (1, 1) 和 (m, n) ，田地内部有一些水平栅栏和垂直栅栏，分别由数组 hFences 和 vFences 给出。
水平栅栏为坐标 (hFences[i], 1) 到 (hFences[i], n)，垂直栅栏为坐标 (1, vFences[i]) 到 (m, vFences[i]) 。
返回通过 移除 一些栅栏（可能不移除）所能形成的最大面积的 正方形 田地的面积，或者如果无法形成正方形田地则返回 -1。
由于答案可能很大，所以请返回结果对 109 + 7 取余 后的值。
注意：田地外围两个水平栅栏（坐标 (1, 1) 到 (1, n) 和坐标 (m, 1) 到 (m, n) ）以及两个垂直栅栏（坐标 (1, 1) 到 (m, 1) 和坐标 (1, n) 到 (m, n) ）所包围。这些栅栏 不能 被移除。

示例 1：

输入：m = 4, n = 3, hFences = [2,3], vFences = [2]
输出：4
解释：移除位于 2 的水平栅栏和位于 2 的垂直栅栏将得到一个面积为 4 的正方形田地。

示例 2：

输入：m = 6, n = 7, hFences = [2], vFences = [4]
输出：-1
解释：可以证明无法通过移除栅栏形成正方形田地。

提示：

3 <= m, n <= 109
1 <= hFences.length, vFences.length <= 600
1 < hFences[i] < m
1 < vFences[i] < n
hFences 和 vFences 中的元素是唯一的。

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

```

my_solution = Solution()

test_input = { "m": 4, "n": 3, "hFences": [2,3], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 6, "n": 7, "hFences": [2], "vFences": [4] }
assert my_solution.maximizeSquareArea(**test_input) == -1

test_input = { "m": 4, "n": 4, "hFences": [2], "vFences": [2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 8, "n": 5, "hFences": [5,4], "vFences": [4] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 4, "n": 5, "hFences": [2], "vFences": [4] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 5, "n": 6, "hFences": [4,2,3], "vFences": [4,5] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 3, "n": 9, "hFences": [2], "vFences": [8,6,5,4] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 6, "n": 4, "hFences": [3], "vFences": [3,2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 7, "n": 4, "hFences": [2,3,6,5], "vFences": [3,2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 8, "n": 8, "hFences": [2,3,6,7], "vFences": [6,5,7,4,2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 49

test_input = { "m": 9, "n": 9, "hFences": [2,4], "vFences": [6,4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 64

test_input = { "m": 7, "n": 7, "hFences": [4,3], "vFences": [2,6] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 4, "n": 6, "hFences": [2], "vFences": [3,4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 8, "n": 6, "hFences": [7,5,2,4,3], "vFences": [5,3] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 9, "n": 3, "hFences": [7,4,5], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 4, "n": 3, "hFences": [3], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 4, "n": 3, "hFences": [3,2], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 8, "n": 6, "hFences": [6,4,3,7,2,5], "vFences": [5,3,4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 8, "n": 8, "hFences": [6,3,7,5], "vFences": [6,2,7] }
assert my_solution.maximizeSquareArea(**test_input) == 49

test_input = { "m": 5, "n": 5, "hFences": [4,3], "vFences": [4] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 5, "n": 3, "hFences": [4], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 1

test_input = { "m": 7, "n": 9, "hFences": [5], "vFences": [2,7,6,8,3] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 8, "n": 6, "hFences": [5,4,6,7,3], "vFences": [5,3] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 9, "n": 7, "hFences": [6,4,7,5,8], "vFences": [6,4,2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 6, "n": 7, "hFences": [5], "vFences": [5,3,6] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 3, "n": 3, "hFences": [2], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 7, "n": 8, "hFences": [4,6,2,5,3], "vFences": [3,5,2,4,7] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 3, "n": 5, "hFences": [2], "vFences": [4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 4, "n": 3, "hFences": [2], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 9, "n": 3, "hFences": [3], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 6, "n": 7, "hFences": [4,2,3,5], "vFences": [3,5,6] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 8, "n": 4, "hFences": [6,3,2,4,7,5], "vFences": [2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 4, "n": 4, "hFences": [2], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 3, "n": 6, "hFences": [2], "vFences": [4,3,5] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 8, "n": 6, "hFences": [5], "vFences": [4,2,5] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 9, "n": 9, "hFences": [5,4,2], "vFences": [8,4,3,5,6] }
assert my_solution.maximizeSquareArea(**test_input) == 64

test_input = { "m": 5, "n": 9, "hFences": [3,2,4], "vFences": [7,6,5] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 5, "n": 5, "hFences": [4,3,2], "vFences": [3,4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 7, "n": 4, "hFences": [5,2,4], "vFences": [3] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 8, "n": 5, "hFences": [4,6,2,3], "vFences": [4] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 9, "n": 5, "hFences": [6], "vFences": [3] }
assert my_solution.maximizeSquareArea(**test_input) == -1

test_input = { "m": 9, "n": 4, "hFences": [2,8,3,7,4,6,5], "vFences": [2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 5, "n": 8, "hFences": [2,3,4], "vFences": [3,5,6,4] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 9, "n": 6, "hFences": [7,3,4,5,8,2], "vFences": [5,3,2,4] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 5, "n": 4, "hFences": [4], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 9, "n": 6, "hFences": [2,5], "vFences": [5,2] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 6, "n": 9, "hFences": [4,5,2], "vFences": [5,7,8,2,3,6] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 4, "n": 5, "hFences": [2], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 9, "n": 6, "hFences": [2,4], "vFences": [5,3] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 4, "n": 7, "hFences": [2], "vFences": [4,3,6,2,5] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 8, "n": 3, "hFences": [3,2,5], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 6, "n": 8, "hFences": [4,2,3,5], "vFences": [7,4,5,6] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 3, "n": 5, "hFences": [2], "vFences": [3] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 8, "n": 8, "hFences": [2,5,6], "vFences": [3,7,4,2,5] }
assert my_solution.maximizeSquareArea(**test_input) == 49

test_input = { "m": 8, "n": 7, "hFences": [3,4,7], "vFences": [2,6,3,4] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 7, "n": 4, "hFences": [3,6,5], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 5, "n": 6, "hFences": [2,3], "vFences": [3,2,5] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 6, "n": 7, "hFences": [5], "vFences": [4,2,5,6] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 8, "n": 8, "hFences": [4,5,2,7], "vFences": [5,3,4,2,7,6] }
assert my_solution.maximizeSquareArea(**test_input) == 49

test_input = { "m": 7, "n": 9, "hFences": [6,3,4], "vFences": [8,6,2] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 7, "n": 4, "hFences": [3,4,6], "vFences": [3,2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 6, "n": 8, "hFences": [5,4,3], "vFences": [5,7,3,2,6,4] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 8, "n": 9, "hFences": [2,3,4,7,6,5], "vFences": [3,7,8] }
assert my_solution.maximizeSquareArea(**test_input) == 49

test_input = { "m": 3, "n": 4, "hFences": [2], "vFences": [2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 9, "n": 9, "hFences": [8,5,6,2,7], "vFences": [8,6,4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 64

test_input = { "m": 7, "n": 6, "hFences": [4,5], "vFences": [5,3] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 5, "n": 4, "hFences": [2], "vFences": [3] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 5, "n": 5, "hFences": [3], "vFences": [3,4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 9, "n": 7, "hFences": [3], "vFences": [3,2,5,4] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 8, "n": 6, "hFences": [4], "vFences": [5,2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 6, "n": 9, "hFences": [3,4,2], "vFences": [3,2,8] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 7, "n": 6, "hFences": [3,6,5,2,4], "vFences": [2,3,5,4] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 7, "n": 3, "hFences": [5,3,6,4], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 4, "n": 7, "hFences": [3], "vFences": [2] }
assert my_solution.maximizeSquareArea(**test_input) == 1

test_input = { "m": 3, "n": 7, "hFences": [2], "vFences": [4,3,2,6,5] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 5, "n": 9, "hFences": [2,4], "vFences": [4,7] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 5, "n": 9, "hFences": [4,2], "vFences": [8,7,3,2,6,4] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 3, "n": 8, "hFences": [2], "vFences": [3,7,2,5,4] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 4, "n": 7, "hFences": [2,3], "vFences": [4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 8, "n": 9, "hFences": [7,6,3,2,5,4], "vFences": [3,2,6] }
assert my_solution.maximizeSquareArea(**test_input) == 49

test_input = { "m": 7, "n": 8, "hFences": [6], "vFences": [5] }
assert my_solution.maximizeSquareArea(**test_input) == -1

test_input = { "m": 9, "n": 7, "hFences": [2,7,8,5], "vFences": [6,3] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 9, "n": 9, "hFences": [4,7,2,5,8,6], "vFences": [7,6,4,5,8,2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 64

test_input = { "m": 7, "n": 7, "hFences": [6,3,2,5], "vFences": [6,3] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 7, "n": 7, "hFences": [5], "vFences": [2,3,6] }
assert my_solution.maximizeSquareArea(**test_input) == 36

test_input = { "m": 4, "n": 9, "hFences": [3], "vFences": [4,3,7,6,8,5,2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 4, "n": 5, "hFences": [2,3], "vFences": [3,4] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 3, "n": 7, "hFences": [2], "vFences": [3,6] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 4, "n": 9, "hFences": [3,2], "vFences": [4,6] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 9, "n": 9, "hFences": [5], "vFences": [6,5,2,7,3,8] }
assert my_solution.maximizeSquareArea(**test_input) == 64

test_input = { "m": 5, "n": 6, "hFences": [3,4,2], "vFences": [5,3,2] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 5, "n": 6, "hFences": [3,2], "vFences": [5] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 5, "n": 5, "hFences": [3,4], "vFences": [3,2,4] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 9, "n": 5, "hFences": [7,5,8], "vFences": [4,2,3] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 3, "n": 6, "hFences": [2], "vFences": [2,5,4] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 5, "n": 9, "hFences": [4,2,3], "vFences": [8,3,5,6,4,2] }
assert my_solution.maximizeSquareArea(**test_input) == 16

test_input = { "m": 4, "n": 7, "hFences": [3,2], "vFences": [5] }
assert my_solution.maximizeSquareArea(**test_input) == 4

test_input = { "m": 6, "n": 9, "hFences": [4,2], "vFences": [3,4,7,2] }
assert my_solution.maximizeSquareArea(**test_input) == 25

test_input = { "m": 6, "n": 5, "hFences": [4], "vFences": [3,2] }
assert my_solution.maximizeSquareArea(**test_input) == 9

test_input = { "m": 8, "n": 5, "hFences": [6,7,4,5,2], "vFences": [4] }
assert my_solution.maximizeSquareArea(**test_input) == 16


minimum-cost-to-convert-string-i

Minimum Cost to Convert String I

Prompt:
"""
给你两个下标从 0 开始的字符串 source 和 target ，它们的长度均为 n 并且由 小写 英文字母组成。
另给你两个下标从 0 开始的字符数组 original 和 changed ，以及一个整数数组 cost ，其中 cost[i] 代表将字符 original[i] 更改为字符 changed[i] 的成本。
你从字符串 source 开始。在一次操作中，如果 存在 任意 下标 j 满足 cost[j] == z 、original[j] == x 以及 changed[j] == y 。你就可以选择字符串中的一个字符 x 并以 z 的成本将其更改为字符 y 。
返回将字符串 source 转换为字符串 target 所需的 最小 成本。如果不可能完成转换，则返回 -1 。
注意，可能存在下标 i 、j 使得 original[j] == original[i] 且 changed[j] == changed[i] 。

示例 1：

输入：source = "abcd", target = "acbe", original = ["a","b","c","c","e","d"], changed = ["b","c","b","e","b","e"], cost = [2,5,5,1,2,20]
输出：28
解释：将字符串 "abcd" 转换为字符串 "acbe" ：
- 更改下标 1 处的值 'b' 为 'c' ，成本为 5 。
- 更改下标 2 处的值 'c' 为 'e' ，成本为 1 。
- 更改下标 2 处的值 'e' 为 'b' ，成本为 2 。
- 更改下标 3 处的值 'd' 为 'e' ，成本为 20 。
产生的总成本是 5 + 1 + 2 + 20 = 28 。
可以证明这是可能的最小成本。

示例 2：

输入：source = "aaaa", target = "bbbb", original = ["a","c"], changed = ["c","b"], cost = [1,2]
输出：12
解释：要将字符 'a' 更改为 'b'：
- 将字符 'a' 更改为 'c'，成本为 1
- 将字符 'c' 更改为 'b'，成本为 2
产生的总成本是 1 + 2 = 3。
将所有 'a' 更改为 'b'，产生的总成本是 3 * 4 = 12 。

示例 3：

输入：source = "abcd", target = "abce", original = ["a"], changed = ["e"], cost = [10000]
输出：-1
解释：无法将 source 字符串转换为 target 字符串，因为下标 3 处的值无法从 'd' 更改为 'e' 。

提示：

1 <= source.length == target.length <= 105
source、target 均由小写英文字母组成
1 <= cost.length== original.length == changed.length <= 2000
original[i]、changed[i] 是小写英文字母
1 <= cost[i] <= 106
original[i] != changed[i]
"""
class Solution:
    def minimumCost(self, source: str, target: str, original: List[str], changed: List[str], cost: List[int]) -> int:

给你两个下标从 0 开始的字符串 source 和 target ，它们的长度均为 n 并且由 小写 英文字母组成。
另给你两个下标从 0 开始的字符数组 original 和 changed ，以及一个整数数组 cost ，其中 cost[i] 代表将字符 original[i] 更改为字符 changed[i] 的成本。
你从字符串 source 开始。在一次操作中，如果 存在 任意 下标 j 满足 cost[j] == z 、original[j] == x 以及 changed[j] == y 。你就可以选择字符串中的一个字符 x 并以 z 的成本将其更改为字符 y 。
返回将字符串 source 转换为字符串 target 所需的 最小 成本。如果不可能完成转换，则返回 -1 。
注意，可能存在下标 i 、j 使得 original[j] == original[i] 且 changed[j] == changed[i] 。

示例 1：

输入：source = "abcd", target = "acbe", original = ["a","b","c","c","e","d"], changed = ["b","c","b","e","b","e"], cost = [2,5,5,1,2,20]
输出：28
解释：将字符串 "abcd" 转换为字符串 "acbe" ：
- 更改下标 1 处的值 'b' 为 'c' ，成本为 5 。
- 更改下标 2 处的值 'c' 为 'e' ，成本为 1 。
- 更改下标 2 处的值 'e' 为 'b' ，成本为 2 。
- 更改下标 3 处的值 'd' 为 'e' ，成本为 20 。
产生的总成本是 5 + 1 + 2 + 20 = 28 。
可以证明这是可能的最小成本。

示例 2：

输入：source = "aaaa", target = "bbbb", original = ["a","c"], changed = ["c","b"], cost = [1,2]
输出：12
解释：要将字符 'a' 更改为 'b'：
- 将字符 'a' 更改为 'c'，成本为 1
- 将字符 'c' 更改为 'b'，成本为 2
产生的总成本是 1 + 2 = 3。
将所有 'a' 更改为 'b'，产生的总成本是 3 * 4 = 12 。

示例 3：

输入：source = "abcd", target = "abce", original = ["a"], changed = ["e"], cost = [10000]
输出：-1
解释：无法将 source 字符串转换为 target 字符串，因为下标 3 处的值无法从 'd' 更改为 'e' 。

提示：

1 <= source.length == target.length <= 105
source、target 均由小写英文字母组成
1 <= cost.length== original.length == changed.length <= 2000
original[i]、changed[i] 是小写英文字母
1 <= cost[i] <= 106
original[i] != changed[i]

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

```

my_solution = Solution()

test_input = { "source": "abcd", "target": "acbe", "original": ["a","b","c","c","e","d"], "changed": ["b","c","b","e","b","e"], "cost": [2,5,5,1,2,20] }
assert my_solution.minimumCost(**test_input) == 28

test_input = { "source": "aaaa", "target": "bbbb", "original": ["a","c"], "changed": ["c","b"], "cost": [1,2] }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "source": "abcd", "target": "abce", "original": ["a"], "changed": ["e"], "cost": [10000] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "aaaabadaaa", "target": "dbdadddbad", "original": ["c","a","c","a","a","b","b","b","d","d","c"], "changed": ["a","c","b","d","b","c","a","d","c","b","d"], "cost": [7,8,11,9,7,6,4,6,9,5,9] }
assert my_solution.minimumCost(**test_input) == 56

test_input = { "source": "aaadbdcdac", "target": "cdbabaddba", "original": ["a","c","b","d","b","a","c"], "changed": ["c","a","d","b","c","b","d"], "cost": [7,2,1,3,6,1,7] }
assert my_solution.minimumCost(**test_input) == 39

test_input = { "source": "aababdaacb", "target": "bcdcdcbdcb", "original": ["a","d","d","a","c","b","c","a","c","d","b","b"], "changed": ["b","c","b","d","a","a","b","c","d","a","c","d"], "cost": [11,4,3,2,7,11,7,6,9,2,1,7] }
assert my_solution.minimumCost(**test_input) == 42

test_input = { "source": "aababdbddc", "target": "adcbbbcdba", "original": ["a","d","b","a","d","c","d","b"], "changed": ["b","a","d","c","c","a","b","a"], "cost": [10,6,8,3,6,10,8,6] }
assert my_solution.minimumCost(**test_input) == 72

test_input = { "source": "aabbcabbdb", "target": "acddbabbdd", "original": ["c","d","c","a","d","c","a","d","b","a","b"], "changed": ["d","b","a","c","c","b","b","a","d","d","c"], "cost": [5,3,8,10,9,7,8,7,5,1,10] }
assert my_solution.minimumCost(**test_input) == 32

test_input = { "source": "aabbddccbc", "target": "abbbaabaca", "original": ["a","b","c","b","a","d"], "changed": ["d","c","b","d","b","b"], "cost": [3,8,7,6,7,10] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "aabdbaabaa", "target": "bdaacabcab", "original": ["b","d","d","a","c","c","a","d","a","b"], "changed": ["c","c","b","d","b","d","b","a","c","a"], "cost": [9,1,7,9,2,1,3,8,8,2] }
assert my_solution.minimumCost(**test_input) == 43

test_input = { "source": "aacacaaccd", "target": "dadaacaabd", "original": ["c","c","a","a","d","b","d","d"], "changed": ["b","d","d","b","b","c","c","a"], "cost": [7,8,9,11,4,6,9,10] }
assert my_solution.minimumCost(**test_input) == 77

test_input = { "source": "aacbabbacc", "target": "adbdbcbdaa", "original": ["c","b","a","b","a","c","d","c","d"], "changed": ["b","c","b","d","d","a","b","d","c"], "cost": [2,6,7,4,7,4,3,5,6] }
assert my_solution.minimumCost(**test_input) == 41

test_input = { "source": "aacbbabdad", "target": "ddadcababd", "original": ["d","b","c","a","b","c","d","c","b","a","a"], "changed": ["c","d","d","b","c","b","b","a","a","c","d"], "cost": [7,10,4,2,7,4,4,4,6,2,8] }
assert my_solution.minimumCost(**test_input) == 45

test_input = { "source": "aacbbbbcab", "target": "cdacdcddac", "original": ["b","d","c","c","b","a"], "changed": ["c","c","b","a","a","d"], "cost": [4,7,9,11,3,4] }
assert my_solution.minimumCost(**test_input) == 67

test_input = { "source": "aacbcabcad", "target": "bbcadddcdd", "original": ["b","a","d","a","b","c","a","d","d","b"], "changed": ["d","b","b","d","c","a","c","c","a","a"], "cost": [7,7,9,8,6,3,8,2,1,5] }
assert my_solution.minimumCost(**test_input) == 53

test_input = { "source": "aacbdbcdca", "target": "bbbdbcaacd", "original": ["a","c","b","d","d","a","c","d"], "changed": ["c","b","c","c","b","d","d","a"], "cost": [9,5,4,1,2,4,7,1] }
assert my_solution.minimumCost(**test_input) == 47

test_input = { "source": "aadbbcdbbd", "target": "badddbdbac", "original": ["c","d","c","d","b","a"], "changed": ["b","b","a","a","a","d"], "cost": [11,4,7,8,5,2] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "aadbccbddd", "target": "cacdbabadc", "original": ["d","b","c","d","a","a","c","b"], "changed": ["c","c","b","b","b","d","a","a"], "cost": [5,8,7,2,4,7,1,5] }
assert my_solution.minimumCost(**test_input) == 46

test_input = { "source": "aadbddcabd", "target": "bdcdccbada", "original": ["d","a","a","b","d","b"], "changed": ["b","c","d","c","a","d"], "cost": [6,10,5,8,11,4] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "aaddadccad", "target": "cbaaadbcba", "original": ["c","a","a","d","c","c","b","b","a","d"], "changed": ["a","c","d","c","d","b","d","c","b","b"], "cost": [1,10,2,8,9,1,9,10,5,1] }
assert my_solution.minimumCost(**test_input) == 44

test_input = { "source": "aaddadcdba", "target": "caaaccbbca", "original": ["b","b","c","d","b","c","a","a"], "changed": ["a","d","d","a","c","b","c","b"], "cost": [11,7,10,8,7,5,10,10] }
assert my_solution.minimumCost(**test_input) == 84

test_input = { "source": "abaacbbcaa", "target": "bdbdbcbdcd", "original": ["d","a","d","a","b","b"], "changed": ["a","d","b","b","a","c"], "cost": [10,9,8,11,4,11] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "abacaadcba", "target": "cadbadcdbd", "original": ["b","d","c","a","b","d","b"], "changed": ["a","b","b","b","c","a","d"], "cost": [9,10,6,2,7,10,9] }
assert my_solution.minimumCost(**test_input) == 89

test_input = { "source": "abacbadadc", "target": "aabbdaaccb", "original": ["d","a","b","d","a","a","c","b","c","c","d","b"], "changed": ["c","b","a","a","d","c","b","c","d","a","b","d"], "cost": [2,10,3,6,4,1,5,5,11,4,2,1] }
assert my_solution.minimumCost(**test_input) == 28

test_input = { "source": "abadbbabcd", "target": "cdcbdddcbb", "original": ["d","d","b","a","c","c","c","a"], "changed": ["c","a","a","c","b","d","a","d"], "cost": [2,10,11,7,6,11,7,1] }
assert my_solution.minimumCost(**test_input) == 79

test_input = { "source": "abadcadacc", "target": "cbabaddcba", "original": ["a","d","a","b","c","a","d","b","b","d","c","c"], "changed": ["b","b","d","d","a","c","a","c","a","c","d","b"], "cost": [7,6,11,11,8,10,4,11,2,3,11,7] }
assert my_solution.minimumCost(**test_input) == 60

test_input = { "source": "abadcdadac", "target": "baddbccdac", "original": ["d","c","d","c","b","a"], "changed": ["b","b","c","a","d","d"], "cost": [8,5,9,1,10,2] }
assert my_solution.minimumCost(**test_input) == 57

test_input = { "source": "abbaadacba", "target": "cdbbcadddd", "original": ["d","a","d","c","b","b","c","d","c","a","a"], "changed": ["a","c","c","d","a","d","a","b","b","d","b"], "cost": [8,3,5,8,3,9,3,4,11,4,9] }
assert my_solution.minimumCost(**test_input) == 50

test_input = { "source": "abbaddaacd", "target": "ccbbaccacc", "original": ["d","d","a","b","c","b"], "changed": ["a","c","c","d","b","c"], "cost": [9,8,2,8,3,1] }
assert my_solution.minimumCost(**test_input) == 35

test_input = { "source": "abbbcabddb", "target": "bbccdbbadc", "original": ["c","d","c","a","b","d","d","a","b","b"], "changed": ["d","a","b","c","c","b","c","d","a","d"], "cost": [3,6,9,4,9,6,9,6,10,7] }
assert my_solution.minimumCost(**test_input) == 60

test_input = { "source": "abbbcbabab", "target": "abcacbaddd", "original": ["b","c","a","c","a","d","d","c"], "changed": ["a","b","d","a","b","b","c","d"], "cost": [11,5,8,1,7,7,1,2] }
assert my_solution.minimumCost(**test_input) == 77

test_input = { "source": "abbcaccabb", "target": "ddddddcacc", "original": ["a","b","c","b","a","c","c"], "changed": ["c","c","d","a","d","a","b"], "cost": [2,6,10,11,9,7,3] }
assert my_solution.minimumCost(**test_input) == 82

test_input = { "source": "abbcaccdba", "target": "accadababc", "original": ["d","a","a","c","b","d"], "changed": ["c","d","b","a","a","b"], "cost": [7,4,10,11,5,5] }
assert my_solution.minimumCost(**test_input) == 99

test_input = { "source": "abbdaccada", "target": "acddaccddc", "original": ["b","b","c","a","d","a","d"], "changed": ["a","c","b","b","b","c","c"], "cost": [4,9,3,1,11,3,3] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "abcabdaddb", "target": "dcbadaaacc", "original": ["d","b","a","a","c","c"], "changed": ["c","c","d","b","b","a"], "cost": [3,3,9,3,7,6] }
assert my_solution.minimumCost(**test_input) == 61

test_input = { "source": "abcadcabaa", "target": "bbbdddcaba", "original": ["b","d","c","d","a","c","b","b"], "changed": ["c","b","a","a","c","b","d","a"], "cost": [1,8,4,3,8,3,11,5] }
assert my_solution.minimumCost(**test_input) == 74

test_input = { "source": "abccabacaa", "target": "aaabacbcbb", "original": ["c","c","d","a","d","b","c","b","d","a"], "changed": ["b","a","a","b","b","d","d","a","c","c"], "cost": [9,10,8,6,9,10,2,6,6,8] }
assert my_solution.minimumCost(**test_input) == 57

test_input = { "source": "abdaababbb", "target": "dbdadabadc", "original": ["a","c","c","b","d","a","b"], "changed": ["c","a","b","c","b","b","d"], "cost": [3,4,6,1,8,11,6] }
assert my_solution.minimumCost(**test_input) == 56

test_input = { "source": "abdbaaacaa", "target": "abbbccccad", "original": ["a","a","c","b","d","d","b"], "changed": ["d","b","b","a","a","b","c"], "cost": [3,10,7,2,5,7,3] }
assert my_solution.minimumCost(**test_input) == 49

test_input = { "source": "abdcbdbccc", "target": "dbbcdcabba", "original": ["c","c","d","b","a","c","a","d","b","d","a","b"], "changed": ["d","a","b","d","c","b","b","a","c","c","d","a"], "cost": [9,5,9,6,5,5,5,10,7,7,3,6] }
assert my_solution.minimumCost(**test_input) == 46

test_input = { "source": "acabbbdbdb", "target": "accbccbbab", "original": ["b","d","c","d","b","c"], "changed": ["a","a","a","c","d","d"], "cost": [7,7,10,9,7,1] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "acadadccbb", "target": "dcaaabbbdd", "original": ["a","c","c","a","d","b","b","d","b","a"], "changed": ["d","d","b","b","c","d","a","a","c","c"], "cost": [1,2,1,4,9,4,8,5,11,7] }
assert my_solution.minimumCost(**test_input) == 25

test_input = { "source": "acadbbcdcb", "target": "bcacabdcdd", "original": ["a","b","d","b","b","c","a"], "changed": ["d","c","c","a","d","b","b"], "cost": [3,6,3,10,11,3,6] }
assert my_solution.minimumCost(**test_input) == 61

test_input = { "source": "acaddccaad", "target": "daacadcdda", "original": ["c","c","a","b","b","a","b","d","c","a","d"], "changed": ["a","b","b","d","a","d","c","b","d","c","c"], "cost": [10,8,4,8,3,1,2,8,11,8,6] }
assert my_solution.minimumCost(**test_input) == 52

test_input = { "source": "acbbabcaac", "target": "bdcbaadcab", "original": ["d","c","a","c","b","a","a","b","c","d"], "changed": ["a","a","d","d","c","c","b","a","b","c"], "cost": [9,11,8,6,11,11,1,1,9,9] }
assert my_solution.minimumCost(**test_input) == 45

test_input = { "source": "accabbadbc", "target": "adbbccbcbd", "original": ["a","c","a","d","b","a","c","c","b","b"], "changed": ["c","d","b","c","d","d","b","a","c","a"], "cost": [7,10,9,3,2,5,1,8,11,2] }
assert my_solution.minimumCost(**test_input) == 36

test_input = { "source": "accabbdddd", "target": "cacdccbcad", "original": ["c","a","d","b","d","c","a","b","b","c","d"], "changed": ["d","b","a","d","c","a","d","a","c","b","b"], "cost": [11,6,6,4,7,11,2,7,7,7,2] }
assert my_solution.minimumCost(**test_input) == 51

test_input = { "source": "accbaadbdb", "target": "baccbaacbb", "original": ["b","b","a","d","d","a","c"], "changed": ["a","d","d","b","a","c","a"], "cost": [9,11,6,7,4,2,2] }
assert my_solution.minimumCost(**test_input) == 61

test_input = { "source": "accbddaaab", "target": "baddbaabbd", "original": ["a","b","c","d","d","b","d","b"], "changed": ["b","a","a","b","a","c","c","d"], "cost": [6,3,4,6,1,6,10,6] }
assert my_solution.minimumCost(**test_input) == 57

test_input = { "source": "acccbcdccb", "target": "bdadccdbad", "original": ["a","b","c","c","a","d","d"], "changed": ["b","c","a","d","c","a","c"], "cost": [8,1,1,9,3,10,4] }
assert my_solution.minimumCost(**test_input) == 48

test_input = { "source": "accccbccda", "target": "daadbbcaac", "original": ["a","c","a","a","d","d"], "changed": ["c","d","d","b","b","c"], "cost": [3,6,6,10,9,8] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "acdacbdadb", "target": "aacccbbacd", "original": ["b","b","a","a","d","c"], "changed": ["d","a","b","d","a","a"], "cost": [6,1,9,6,8,11] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "acdbcdadbd", "target": "daaadaaadd", "original": ["c","a","b","b","b","d","a"], "changed": ["d","c","d","c","a","b","d"], "cost": [3,9,4,6,1,9,3] }
assert my_solution.minimumCost(**test_input) == 54

test_input = { "source": "acddadcbca", "target": "ddaabaaaac", "original": ["b","d","c","a","b","d","c","b","d","c","a"], "changed": ["c","a","b","c","d","c","a","a","b","d","d"], "cost": [7,8,2,10,1,7,8,1,1,11,4] }
assert my_solution.minimumCost(**test_input) == 35

test_input = { "source": "adaadcaddd", "target": "cdddbdccad", "original": ["c","c","c","d","b","a","d"], "changed": ["d","a","b","b","d","b","c"], "cost": [10,9,2,2,7,1,10] }
assert my_solution.minimumCost(**test_input) == 92

test_input = { "source": "adaaddacba", "target": "aabbddbbdd", "original": ["c","b","a","b","c","b"], "changed": ["b","c","b","a","d","d"], "cost": [10,7,7,6,8,5] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "adacdcdacd", "target": "ccbabbbbdc", "original": ["a","b","c","a","d","b","a","c"], "changed": ["c","d","d","d","a","c","b","a"], "cost": [4,3,1,1,6,4,10,6] }
assert my_solution.minimumCost(**test_input) == 99

test_input = { "source": "adadbabcdd", "target": "abbcdcbdba", "original": ["c","d","b","a","c","b","a"], "changed": ["d","b","d","b","b","a","c"], "cost": [11,10,6,1,5,3,8] }
assert my_solution.minimumCost(**test_input) == 80

test_input = { "source": "adadcabbda", "target": "cabadddccc", "original": ["c","a","b","b","a","d","d"], "changed": ["b","d","d","c","b","c","b"], "cost": [7,2,8,4,4,4,7] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "adbaabacdc", "target": "bccbbadcdc", "original": ["c","b","b","d","c","a","b"], "changed": ["b","a","c","a","a","d","d"], "cost": [5,2,6,1,7,7,1] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "adbadbaacb", "target": "bccdbdccab", "original": ["d","a","c","b","c","d","a","b","c","b","a","d"], "changed": ["a","c","b","c","a","b","b","d","d","a","d","c"], "cost": [3,7,7,9,2,9,10,2,9,5,11,8] }
assert my_solution.minimumCost(**test_input) == 65

test_input = { "source": "adbcdaddda", "target": "cbdccabcbc", "original": ["c","a","d","d","b","b","b"], "changed": ["a","c","c","a","d","c","a"], "cost": [8,5,5,10,10,3,9] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "adcacaaabb", "target": "daaadadcbb", "original": ["d","b","a","a","d","c","b","b","d","c","c","a"], "changed": ["b","c","d","c","c","a","a","d","a","b","d","b"], "cost": [2,3,2,4,5,9,11,3,10,1,9,2] }
assert my_solution.minimumCost(**test_input) == 31

test_input = { "source": "adcbbbdada", "target": "cdaabadcdc", "original": ["a","a","b","c","d","b","d"], "changed": ["c","d","c","d","a","a","c"], "cost": [11,11,2,8,5,7,5] }
assert my_solution.minimumCost(**test_input) == 60

test_input = { "source": "adccbabbca", "target": "dcdbbdabba", "original": ["a","d","d","b","c","b","a"], "changed": ["c","b","c","c","a","d","d"], "cost": [5,10,10,1,6,7,7] }
assert my_solution.minimumCost(**test_input) == 90

test_input = { "source": "adcdcbacab", "target": "acddaddadc", "original": ["b","d","c","d","c","d","b","c","a","a","a","b"], "changed": ["a","b","b","c","a","a","d","d","c","b","d","c"], "cost": [2,11,11,9,1,3,6,9,6,4,8,5] }
assert my_solution.minimumCost(**test_input) == 47

test_input = { "source": "addbaccbbd", "target": "cabdcdadcc", "original": ["b","d","d","d","c","b","a","c","c"], "changed": ["a","c","a","b","b","d","d","a","d"], "cost": [10,11,5,6,10,1,4,8,8] }
assert my_solution.minimumCost(**test_input) == 82

test_input = { "source": "addbacdaac", "target": "abddcadbcb", "original": ["d","a","c","b","a","c","a","d","c","d","b"], "changed": ["c","c","b","d","d","d","b","b","a","a","c"], "cost": [9,2,9,4,11,6,10,3,7,2,5] }
assert my_solution.minimumCost(**test_input) == 37

test_input = { "source": "addbcccdcb", "target": "cbbdbddacb", "original": ["d","c","a","a","b","b","c"], "changed": ["c","d","b","d","d","c","b"], "cost": [2,6,4,3,7,7,8] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "addcadccaa", "target": "dbbcaccabc", "original": ["a","b","d","b","d","a","c","b","a","c"], "changed": ["c","d","a","c","b","b","d","a","d","a"], "cost": [8,11,5,1,11,4,3,8,11,4] }
assert my_solution.minimumCost(**test_input) == 49

test_input = { "source": "addcdbdadb", "target": "bcabdcccbd", "original": ["b","b","a","c","d","a","b","c","a"], "changed": ["a","c","c","a","a","b","d","b","d"], "cost": [2,4,8,8,3,5,2,7,2] }
assert my_solution.minimumCost(**test_input) == 59

test_input = { "source": "adddbbdbdb", "target": "cdbadcaccc", "original": ["b","c","c","b","a","c","b","a","a","d","d"], "changed": ["d","a","b","a","b","d","c","c","d","a","c"], "cost": [1,1,1,8,6,9,3,6,5,3,10] }
assert my_solution.minimumCost(**test_input) == 40

test_input = { "source": "adddccacca", "target": "cdcdcccdac", "original": ["d","c","a","d","b","b","b","a","d","a","c","c"], "changed": ["c","a","c","a","d","a","c","b","b","d","d","b"], "cost": [7,7,6,10,1,1,11,5,3,2,10,3] }
assert my_solution.minimumCost(**test_input) == 33

test_input = { "source": "baacbbcdaa", "target": "abdbdbbabd", "original": ["c","d","c","b","a","c","b","d","b"], "changed": ["d","c","b","a","d","a","d","a","c"], "cost": [9,5,5,2,9,4,5,3,6] }
assert my_solution.minimumCost(**test_input) == 76

test_input = { "source": "baadcdabbc", "target": "acbccadccd", "original": ["b","b","a","a","a","d","d","d","c","c","b"], "changed": ["c","a","c","b","d","c","a","b","b","d","d"], "cost": [8,6,5,10,11,1,1,6,3,1,4] }
assert my_solution.minimumCost(**test_input) == 37

test_input = { "source": "baadcdabda", "target": "abdbcdaaca", "original": ["b","b","c","d","d","a","c"], "changed": ["d","a","a","b","c","b","d"], "cost": [11,8,7,3,10,4,1] }
assert my_solution.minimumCost(**test_input) == 48

test_input = { "source": "babababdba", "target": "ccdaaabbac", "original": ["c","d","b","a","d","a","b"], "changed": ["b","a","d","c","c","d","c"], "cost": [8,5,6,2,8,6,8] }
assert my_solution.minimumCost(**test_input) == 55

test_input = { "source": "babbacabba", "target": "adacccdcba", "original": ["c","d","d","d","c","b","b","b","a"], "changed": ["a","b","c","a","d","a","c","d","c"], "cost": [1,1,8,3,2,2,11,8,3] }
assert my_solution.minimumCost(**test_input) == 27

test_input = { "source": "babbadbabc", "target": "ccdabbcbba", "original": ["a","c","d","a","b","d","b","b"], "changed": ["b","d","c","d","a","a","c","d"], "cost": [3,3,1,4,4,8,2,9] }
assert my_solution.minimumCost(**test_input) == 46

test_input = { "source": "bacbddaacb", "target": "dcdaaadcda", "original": ["a","d","a","a","d","c","b","c","c","b"], "changed": ["d","c","c","b","b","b","a","a","d","c"], "cost": [8,5,1,10,8,6,2,1,6,8] }
assert my_solution.minimumCost(**test_input) == 46

test_input = { "source": "baccbbcdcb", "target": "cabadbbacc", "original": ["c","a","c","b","c","d","a","b","d","b"], "changed": ["a","b","b","a","d","b","c","d","c","c"], "cost": [4,4,2,11,9,9,1,4,6,1] }
assert my_solution.minimumCost(**test_input) == 24

test_input = { "source": "bacdbbcdba", "target": "cdcdddbbcd", "original": ["d","a","c","b","d","a","b","c","b","c","d"], "changed": ["c","c","a","d","b","b","a","d","c","b","a"], "cost": [3,8,4,6,5,8,6,2,1,6,2] }
assert my_solution.minimumCost(**test_input) == 39

test_input = { "source": "bacdbccabb", "target": "caaccdbaac", "original": ["c","d","d","a","d","c"], "changed": ["d","b","a","b","c","a"], "cost": [8,4,4,4,3,6] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "bacddacdba", "target": "bcbbaacdda", "original": ["b","c","c","d","d","b","b","d","a","a","c","a"], "changed": ["a","b","d","b","a","c","d","c","c","d","a","b"], "cost": [5,6,7,4,4,8,8,6,8,3,6,11] }
assert my_solution.minimumCost(**test_input) == 30

test_input = { "source": "badaabbaba", "target": "caadbcadcd", "original": ["b","c","a","c","d","a","b","d","d","b","c"], "changed": ["c","a","d","b","a","c","d","c","b","a","d"], "cost": [4,8,6,3,1,8,3,8,3,6,9] }
assert my_solution.minimumCost(**test_input) == 44

test_input = { "source": "badabbbbac", "target": "dacaabbcaa", "original": ["d","b","a","d","c","b","d","c","a","c","a"], "changed": ["b","c","d","c","a","d","a","d","c","b","b"], "cost": [11,5,9,7,11,11,7,9,6,11,5] }
assert my_solution.minimumCost(**test_input) == 50

test_input = { "source": "badaccbdbd", "target": "dbbdacaaab", "original": ["b","d","b","c","b","d","a","d","a","a","c","c"], "changed": ["d","a","a","a","c","b","d","c","b","c","d","b"], "cost": [3,9,3,11,11,6,2,11,11,2,11,1] }
assert my_solution.minimumCost(**test_input) == 39

test_input = { "source": "badadcccba", "target": "bbdbababcc", "original": ["c","c","a","d","d","d"], "changed": ["a","d","b","a","b","c"], "cost": [1,3,2,2,4,4] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "badbbbccdb", "target": "bbbabbccbd", "original": ["a","c","a","c","d","c","d","b","d","b","a"], "changed": ["c","b","d","d","c","a","b","d","a","c","b"], "cost": [5,4,5,3,4,4,6,3,8,11,4] }
assert my_solution.minimumCost(**test_input) == 30

test_input = { "source": "badcbccabc", "target": "bdcaacbcad", "original": ["d","d","c","d","a","b","c","a"], "changed": ["a","c","d","b","b","a","b","d"], "cost": [1,5,4,5,11,10,8,11] }
assert my_solution.minimumCost(**test_input) == 69

test_input = { "source": "badcbdddcd", "target": "cdcbaddadc", "original": ["c","b","c","d","a","b","b","d","a","c","a","d"], "changed": ["a","c","b","a","c","d","a","b","d","d","b","c"], "cost": [3,2,8,9,11,5,11,11,9,2,8,1] }
assert my_solution.minimumCost(**test_input) == 32

test_input = { "source": "baddbcbdbd", "target": "acdbcadabd", "original": ["a","b","b","c","a","a","b","d","c","d","d"], "changed": ["c","a","d","d","b","d","c","c","b","b","a"], "cost": [9,10,5,4,1,5,7,8,11,9,8] }
assert my_solution.minimumCost(**test_input) == 59

test_input = { "source": "baddbdacad", "target": "cadaccbbab", "original": ["b","a","d","a","c","b","d","c","a","d"], "changed": ["d","b","b","d","a","c","a","b","c","c"], "cost": [3,5,6,7,2,4,4,2,3,9] }
assert my_solution.minimumCost(**test_input) == 32

test_input = { "source": "bbacdcdcda", "target": "cbadabbdcb", "original": ["a","d","b","c","b","c","d","a","d"], "changed": ["b","c","d","a","a","b","b","d","a"], "cost": [11,6,2,8,5,7,5,8,9] }
assert my_solution.minimumCost(**test_input) == 64

test_input = { "source": "bbadbbabbb", "target": "cbaaddaddc", "original": ["d","a","b","c","d","c","b"], "changed": ["b","d","c","b","c","d","d"], "cost": [4,10,1,11,7,1,11] }
assert my_solution.minimumCost(**test_input) == -1

test_input = { "source": "bbadcbcbbc", "target": "aaaccbccbb", "original": ["b","d","b","d","a","c","c","a","b"], "changed": ["c","a","a","b","b","a","b","c","d"], "cost": [8,5,9,4,1,10,1,11,4] }
assert my_solution.minimumCost(**test_input) == 39

test_input = { "source": "bbbadaccbb", "target": "dadcaccadb", "original": ["a","d","d","d","c","b","c","b","c","b"], "changed": ["d","b","c","a","b","d","d","c","a","a"], "cost": [10,1,4,6,4,1,10,3,1,6] }
assert my_solution.minimumCost(**test_input) == 41

test_input = { "source": "bbbadcbadb", "target": "aacbdcddcd", "original": ["a","d","d","c","a","b","c","b"], "changed": ["d","b","a","a","c","c","b","d"], "cost": [3,1,1,9,1,2,1,2] }
assert my_solution.minimumCost(**test_input) == 19

test_input = { "source": "bbbbabbcbc", "target": "adacababac", "original": ["a","c","a","b","b","d","d","a","d","b","c"], "changed": ["d","b","c","c","d","a","b","b","c","a","d"], "cost": [7,9,9,7,3,2,6,8,11,5,8] }
assert my_solution.minimumCost(**test_input) == 39

test_input = { "source": "bbbbdacbcd", "target": "cbadccdaaa", "original": ["d","a","c","b","d","c","a","d","b","a"], "changed": ["c","c","b","c","a","d","d","b","d","b"], "cost": [2,9,11,3,6,11,6,4,5,5] }
assert my_solution.minimumCost(**test_input) == 74


minimum-cost-to-convert-string-ii

Minimum Cost to Convert String II

Prompt:
"""
给你两个下标从 0 开始的字符串 source 和 target ，它们的长度均为 n 并且由 小写 英文字母组成。
另给你两个下标从 0 开始的字符串数组 original 和 changed ，以及一个整数数组 cost ，其中 cost[i] 代表将字符串 original[i] 更改为字符串 changed[i] 的成本。
你从字符串 source 开始。在一次操作中，如果 存在 任意 下标 j 满足 cost[j] == z 、original[j] == x 以及 changed[j] == y ，你就可以选择字符串中的 子串 x 并以 z 的成本将其更改为 y 。 你可以执行 任意数量 的操作，但是任两次操作必须满足 以下两个 条件 之一 ：

在两次操作中选择的子串分别是 source[a..b] 和 source[c..d] ，满足 b < c 或 d < a 。换句话说，两次操作中选择的下标 不相交 。
在两次操作中选择的子串分别是 source[a..b] 和 source[c..d] ，满足 a == c 且 b == d 。换句话说，两次操作中选择的下标 相同 。

返回将字符串 source 转换为字符串 target 所需的 最小 成本。如果不可能完成转换，则返回 -1 。
注意，可能存在下标 i 、j 使得 original[j] == original[i] 且 changed[j] == changed[i] 。

示例 1：

输入：source = "abcd", target = "acbe", original = ["a","b","c","c","e","d"], changed = ["b","c","b","e","b","e"], cost = [2,5,5,1,2,20]
输出：28
解释：将 "abcd" 转换为 "acbe"，执行以下操作：
- 将子串 source[1..1] 从 "b" 改为 "c" ，成本为 5 。
- 将子串 source[2..2] 从 "c" 改为 "e" ，成本为 1 。
- 将子串 source[2..2] 从 "e" 改为 "b" ，成本为 2 。
- 将子串 source[3..3] 从 "d" 改为 "e" ，成本为 20 。
产生的总成本是 5 + 1 + 2 + 20 = 28 。
可以证明这是可能的最小成本。

示例 2：

输入：source = "abcdefgh", target = "acdeeghh", original = ["bcd","fgh","thh"], changed = ["cde","thh","ghh"], cost = [1,3,5]
输出：9
解释：将 "abcdefgh" 转换为 "acdeeghh"，执行以下操作：
- 将子串 source[1..3] 从 "bcd" 改为 "cde" ，成本为 1 。
- 将子串 source[5..7] 从 "fgh" 改为 "thh" ，成本为 3 。可以执行此操作，因为下标 [5,7] 与第一次操作选中的下标不相交。
- 将子串 source[5..7] 从 "thh" 改为 "ghh" ，成本为 5 。可以执行此操作，因为下标 [5,7] 与第一次操作选中的下标不相交，且与第二次操作选中的下标相同。
产生的总成本是 1 + 3 + 5 = 9 。
可以证明这是可能的最小成本。

示例 3：

输入：source = "abcdefgh", target = "addddddd", original = ["bcd","defgh"], changed = ["ddd","ddddd"], cost = [100,1578]
输出：-1
解释：无法将 "abcdefgh" 转换为 "addddddd" 。
如果选择子串 source[1..3] 执行第一次操作，以将 "abcdefgh" 改为 "adddefgh" ，你无法选择子串 source[3..7] 执行第二次操作，因为两次操作有一个共用下标 3 。
如果选择子串 source[3..7] 执行第一次操作，以将 "abcdefgh" 改为 "abcddddd" ，你无法选择子串 source[1..3] 执行第二次操作，因为两次操作有一个共用下标 3 。

提示：

1 <= source.length == target.length <= 1000
source、target 均由小写英文字母组成
1 <= cost.length == original.length == changed.length <= 100
1 <= original[i].length == changed[i].length <= source.length
original[i]、changed[i] 均由小写英文字母组成
original[i] != changed[i]
1 <= cost[i] <= 106
"""
class Solution:
    def minimumCost(self, source: str, target: str, original: List[str], changed: List[str], cost: List[int]) -> int:

给你两个下标从 0 开始的字符串 source 和 target ，它们的长度均为 n 并且由 小写 英文字母组成。
另给你两个下标从 0 开始的字符串数组 original 和 changed ，以及一个整数数组 cost ，其中 cost[i] 代表将字符串 original[i] 更改为字符串 changed[i] 的成本。
你从字符串 source 开始。在一次操作中，如果 存在 任意 下标 j 满足 cost[j] == z 、original[j] == x 以及 changed[j] == y ，你就可以选择字符串中的 子串 x 并以 z 的成本将其更改为 y 。 你可以执行 任意数量 的操作，但是任两次操作必须满足 以下两个 条件 之一 ：

在两次操作中选择的子串分别是 source[a..b] 和 source[c..d] ，满足 b < c 或 d < a 。换句话说，两次操作中选择的下标 不相交 。
在两次操作中选择的子串分别是 source[a..b] 和 source[c..d] ，满足 a == c 且 b == d 。换句话说，两次操作中选择的下标 相同 。

返回将字符串 source 转换为字符串 target 所需的 最小 成本。如果不可能完成转换，则返回 -1 。
注意，可能存在下标 i 、j 使得 original[j] == original[i] 且 changed[j] == changed[i] 。

示例 1：

输入：source = "abcd", target = "acbe", original = ["a","b","c","c","e","d"], changed = ["b","c","b","e","b","e"], cost = [2,5,5,1,2,20]
输出：28
解释：将 "abcd" 转换为 "acbe"，执行以下操作：
- 将子串 source[1..1] 从 "b" 改为 "c" ，成本为 5 。
- 将子串 source[2..2] 从 "c" 改为 "e" ，成本为 1 。
- 将子串 source[2..2] 从 "e" 改为 "b" ，成本为 2 。
- 将子串 source[3..3] 从 "d" 改为 "e" ，成本为 20 。
产生的总成本是 5 + 1 + 2 + 20 = 28 。
可以证明这是可能的最小成本。

示例 2：

输入：source = "abcdefgh", target = "acdeeghh", original = ["bcd","fgh","thh"], changed = ["cde","thh","ghh"], cost = [1,3,5]
输出：9
解释：将 "abcdefgh" 转换为 "acdeeghh"，执行以下操作：
- 将子串 source[1..3] 从 "bcd" 改为 "cde" ，成本为 1 。
- 将子串 source[5..7] 从 "fgh" 改为 "thh" ，成本为 3 。可以执行此操作，因为下标 [5,7] 与第一次操作选中的下标不相交。
- 将子串 source[5..7] 从 "thh" 改为 "ghh" ，成本为 5 。可以执行此操作，因为下标 [5,7] 与第一次操作选中的下标不相交，且与第二次操作选中的下标相同。
产生的总成本是 1 + 3 + 5 = 9 。
可以证明这是可能的最小成本。

示例 3：

输入：source = "abcdefgh", target = "addddddd", original = ["bcd","defgh"], changed = ["ddd","ddddd"], cost = [100,1578]
输出：-1
解释：无法将 "abcdefgh" 转换为 "addddddd" 。
如果选择子串 source[1..3] 执行第一次操作，以将 "abcdefgh" 改为 "adddefgh" ，你无法选择子串 source[3..7] 执行第二次操作，因为两次操作有一个共用下标 3 。
如果选择子串 source[3..7] 执行第一次操作，以将 "abcdefgh" 改为 "abcddddd" ，你无法选择子串 source[1..3] 执行第二次操作，因为两次操作有一个共用下标 3 。

提示：

1 <= source.length == target.length <= 1000
source、target 均由小写英文字母组成
1 <= cost.length == original.length == changed.length <= 100
1 <= original[i].length == changed[i].length <= source.length
original[i]、changed[i] 均由小写英文字母组成
original[i] != changed[i]
1 <= cost[i] <= 106

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

```


count-the-number-of-incremovable-subarrays-i

Count the Number of Incremovable Subarrays I

Prompt:
"""
给你一个下标从 0开始的 正整数数组nums。
如果 nums的一个子数组满足：移除这个子数组后剩余元素 严格递增，那么我们称这个子数组为 移除递增子数组。比方说，[5, 3, 4, 6, 7]中的 [3, 4]是一个移除递增子数组，因为移除该子数组后，[5, 3, 4, 6, 7]变为[5, 6, 7]，是严格递增的。
请你返回 nums中 移除递增子数组的总数目。
注意，剩余元素为空的数组也视为是递增的。
子数组 指的是一个数组中一段连续的元素序列。

示例 1：

输入：nums = [1,2,3,4]
输出：10
解释：10 个移除递增子数组分别为：[1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4] 和 [1,2,3,4]。移除任意一个子数组后，剩余元素都是递增的。注意，空数组不是移除递增子数组。

示例 2：

输入：nums = [6,5,7,8]
输出：7
解释：7个移除递增子数组分别为：[5], [6], [5,7], [6,5], [5,7,8], [6,5,7] 和 [6,5,7,8] 。
nums 中只有这 7 个移除递增子数组。

示例 3：

输入：nums = [8,7,6,6]
输出：3
解释：3 个移除递增子数组分别为：[8,7,6], [7,6,6] 和 [8,7,6,6] 。注意 [8,7] 不是移除递增子数组因为移除 [8,7] 后 nums 变为 [6,6] ，它不是严格递增的。

提示：

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

给你一个下标从 0开始的 正整数数组nums。
如果 nums的一个子数组满足：移除这个子数组后剩余元素 严格递增，那么我们称这个子数组为 移除递增子数组。比方说，[5, 3, 4, 6, 7]中的 [3, 4]是一个移除递增子数组，因为移除该子数组后，[5, 3, 4, 6, 7]变为[5, 6, 7]，是严格递增的。
请你返回 nums中 移除递增子数组的总数目。
注意，剩余元素为空的数组也视为是递增的。
子数组 指的是一个数组中一段连续的元素序列。

示例 1：

输入：nums = [1,2,3,4]
输出：10
解释：10 个移除递增子数组分别为：[1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4] 和 [1,2,3,4]。移除任意一个子数组后，剩余元素都是递增的。注意，空数组不是移除递增子数组。

示例 2：

输入：nums = [6,5,7,8]
输出：7
解释：7个移除递增子数组分别为：[5], [6], [5,7], [6,5], [5,7,8], [6,5,7] 和 [6,5,7,8] 。
nums 中只有这 7 个移除递增子数组。

示例 3：

输入：nums = [8,7,6,6]
输出：3
解释：3 个移除递增子数组分别为：[8,7,6], [7,6,6] 和 [8,7,6,6] 。注意 [8,7] 不是移除递增子数组因为移除 [8,7] 后 nums 变为 [6,6] ，它不是严格递增的。

提示：

1 <= nums.length <= 50
1 <= nums[i] <= 50

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

```

my_solution = Solution()

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

test_input = { "nums": [6,5,7,8] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [8,7,6,6] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [5,7] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [5,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

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

test_input = { "nums": [6,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

test_input = { "nums": [9,4] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [9,7] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [9,8] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [10,5] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

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

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

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

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

test_input = { "nums": [2,6,8] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [2,6,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [2,10,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

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

test_input = { "nums": [3,5,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

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

test_input = { "nums": [3,8,8] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [3,10,10] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

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

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

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

test_input = { "nums": [5,9,7] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [6,7,4] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [8,7,4] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [8,7,5] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [8,9,5] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

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

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

test_input = { "nums": [9,6,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [9,9,4] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [10,7,4] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [10,10,6] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

test_input = { "nums": [2,5,7,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 10

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

test_input = { "nums": [3,7,10,6] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [3,8,3,8] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

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

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

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

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

test_input = { "nums": [4,9,10,6] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

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

test_input = { "nums": [5,5,9,5] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [5,10,10,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [6,4,4,9] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [6,5,2,10] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

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

test_input = { "nums": [7,5,1,10] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

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

test_input = { "nums": [7,9,8,8] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [7,10,4,3] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [8,8,1,7] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

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

test_input = { "nums": [10,5,9,5] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

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

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

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

test_input = { "nums": [1,2,8,9,2] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

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

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

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

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

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

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

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

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

test_input = { "nums": [6,1,1,8,10] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7


find-polygon-with-the-largest-perimeter

Find Polygon With the Largest Perimeter

Prompt:
"""
给你一个长度为n的正整数数组nums。
多边形指的是一个至少有 3条边的封闭二维图形。多边形的 最长边一定 小于所有其他边长度之和。
如果你有k（k >= 3）个正数a1，a2，a3, ...，ak 满足a1 <= a2 <= a3 <= ... <= ak 且 a1 + a2 + a3 + ... + ak-1 > ak，那么 一定存在一个k条边的多边形，每条边的长度分别为a1，a2，a3，...，ak。
一个多边形的 周长指的是它所有边之和。
请你返回从 nums中可以构造的 多边形的 最大周长。如果不能构造出任何多边形，请你返回 -1。

示例 1：

输入：nums = [5,5,5]
输出：15
解释：nums 中唯一可以构造的多边形为三角形，每条边的长度分别为 5 ，5 和 5 ，周长为 5 + 5 + 5 = 15 。

示例 2：

输入：nums = [1,12,1,2,5,50,3]
输出：12
解释：最大周长多边形为五边形，每条边的长度分别为 1 ，1 ，2 ，3 和 5 ，周长为 1 + 1 + 2 + 3 + 5 = 12 。
我们无法构造一个包含变长为 12 或者 50 的多边形，因为其他边之和没法大于两者中的任何一个。
所以最大周长为 12 。

示例 3：

输入：nums = [5,5,50]
输出：-1
解释：无法构造任何多边形，因为多边形至少要有 3 条边且 50 > 5 + 5 。

提示：

3 <= n <= 105
1 <= nums[i] <= 109
"""
class Solution:
    def largestPerimeter(self, nums: List[int]) -> int:

给你一个长度为n的正整数数组nums。
多边形指的是一个至少有 3条边的封闭二维图形。多边形的 最长边一定 小于所有其他边长度之和。
如果你有k（k >= 3）个正数a1，a2，a3, ...，ak 满足a1 <= a2 <= a3 <= ... <= ak 且 a1 + a2 + a3 + ... + ak-1 > ak，那么 一定存在一个k条边的多边形，每条边的长度分别为a1，a2，a3，...，ak。
一个多边形的 周长指的是它所有边之和。
请你返回从 nums中可以构造的 多边形的 最大周长。如果不能构造出任何多边形，请你返回 -1。

示例 1：

输入：nums = [5,5,5]
输出：15
解释：nums 中唯一可以构造的多边形为三角形，每条边的长度分别为 5 ，5 和 5 ，周长为 5 + 5 + 5 = 15 。

示例 2：

输入：nums = [1,12,1,2,5,50,3]
输出：12
解释：最大周长多边形为五边形，每条边的长度分别为 1 ，1 ，2 ，3 和 5 ，周长为 1 + 1 + 2 + 3 + 5 = 12 。
我们无法构造一个包含变长为 12 或者 50 的多边形，因为其他边之和没法大于两者中的任何一个。
所以最大周长为 12 。

示例 3：

输入：nums = [5,5,50]
输出：-1
解释：无法构造任何多边形，因为多边形至少要有 3 条边且 50 > 5 + 5 。

提示：

3 <= n <= 105
1 <= nums[i] <= 109

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

```

my_solution = Solution()

test_input = { "nums": [5,5,5] }
assert my_solution.largestPerimeter(**test_input) == 15

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

test_input = { "nums": [5,5,50] }
assert my_solution.largestPerimeter(**test_input) == -1

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

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

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

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

test_input = { "nums": [1,1,5] }
assert my_solution.largestPerimeter(**test_input) == -1

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [1,4,4] }
assert my_solution.largestPerimeter(**test_input) == 9

test_input = { "nums": [1,4,5] }
assert my_solution.largestPerimeter(**test_input) == -1

test_input = { "nums": [1,5,1] }
assert my_solution.largestPerimeter(**test_input) == -1

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

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

test_input = { "nums": [1,5,4] }
assert my_solution.largestPerimeter(**test_input) == -1

test_input = { "nums": [1,5,5] }
assert my_solution.largestPerimeter(**test_input) == 11

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [2,4,4] }
assert my_solution.largestPerimeter(**test_input) == 10

test_input = { "nums": [2,4,5] }
assert my_solution.largestPerimeter(**test_input) == 11

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

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

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

test_input = { "nums": [2,5,4] }
assert my_solution.largestPerimeter(**test_input) == 11

test_input = { "nums": [2,5,5] }
assert my_solution.largestPerimeter(**test_input) == 12

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [3,3,4] }
assert my_solution.largestPerimeter(**test_input) == 10

test_input = { "nums": [3,3,5] }
assert my_solution.largestPerimeter(**test_input) == 11

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

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

test_input = { "nums": [3,4,3] }
assert my_solution.largestPerimeter(**test_input) == 10

test_input = { "nums": [3,4,4] }
assert my_solution.largestPerimeter(**test_input) == 11

test_input = { "nums": [3,4,5] }
assert my_solution.largestPerimeter(**test_input) == 12

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

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

test_input = { "nums": [3,5,3] }
assert my_solution.largestPerimeter(**test_input) == 11

test_input = { "nums": [3,5,4] }
assert my_solution.largestPerimeter(**test_input) == 12

test_input = { "nums": [3,5,5] }
assert my_solution.largestPerimeter(**test_input) == 13

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

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

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

test_input = { "nums": [4,1,4] }
assert my_solution.largestPerimeter(**test_input) == 9

test_input = { "nums": [4,1,5] }
assert my_solution.largestPerimeter(**test_input) == -1

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

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

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

test_input = { "nums": [4,2,4] }
assert my_solution.largestPerimeter(**test_input) == 10

test_input = { "nums": [4,2,5] }
assert my_solution.largestPerimeter(**test_input) == 11

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

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

test_input = { "nums": [4,3,3] }
assert my_solution.largestPerimeter(**test_input) == 10

test_input = { "nums": [4,3,4] }
assert my_solution.largestPerimeter(**test_input) == 11

test_input = { "nums": [4,3,5] }
assert my_solution.largestPerimeter(**test_input) == 12

test_input = { "nums": [4,4,1] }
assert my_solution.largestPerimeter(**test_input) == 9

test_input = { "nums": [4,4,2] }
assert my_solution.largestPerimeter(**test_input) == 10

test_input = { "nums": [4,4,3] }
assert my_solution.largestPerimeter(**test_input) == 11

test_input = { "nums": [4,4,4] }
assert my_solution.largestPerimeter(**test_input) == 12

test_input = { "nums": [4,4,5] }
assert my_solution.largestPerimeter(**test_input) == 13

test_input = { "nums": [4,5,1] }
assert my_solution.largestPerimeter(**test_input) == -1

test_input = { "nums": [4,5,2] }
assert my_solution.largestPerimeter(**test_input) == 11