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

Maximum Square Area by Removing Fences From a Field

Prompt:
"""
There is a large (m - 1) x (n - 1) rectangular field with corners at (1, 1) and (m, n) containing some horizontal and vertical fences given in arrays hFences and vFences respectively.
Horizontal fences are from the coordinates (hFences[i], 1) to (hFences[i], n) and vertical fences are from the coordinates (1, vFences[i]) to (m, vFences[i]).
Return the maximum area of a square field that can be formed by removing some fences (possibly none) or -1 if it is impossible to make a square field.
Since the answer may be large, return it modulo 109 + 7.
Note: The field is surrounded by two horizontal fences from the coordinates (1, 1) to (1, n) and (m, 1) to (m, n) and two vertical fences from the coordinates (1, 1) to (m, 1) and (1, n) to (m, n). These fences cannot be removed.

Example 1:

Input: m = 4, n = 3, hFences = [2,3], vFences = [2]
Output: 4
Explanation: Removing the horizontal fence at 2 and the vertical fence at 2 will give a square field of area 4.

Example 2:

Input: m = 6, n = 7, hFences = [2], vFences = [4]
Output: -1
Explanation: It can be proved that there is no way to create a square field by removing fences.

Constraints:

3 <= m, n <= 109
1 <= hFences.length, vFences.length <= 600
1 < hFences[i] < m
1 < vFences[i] < n
hFences and vFences are unique.
"""
class Solution:
    def maximizeSquareArea(self, m: int, n: int, hFences: List[int], vFences: List[int]) -> int:

There is a large (m - 1) x (n - 1) rectangular field with corners at (1, 1) and (m, n) containing some horizontal and vertical fences given in arrays hFences and vFences respectively.
Horizontal fences are from the coordinates (hFences[i], 1) to (hFences[i], n) and vertical fences are from the coordinates (1, vFences[i]) to (m, vFences[i]).
Return the maximum area of a square field that can be formed by removing some fences (possibly none) or -1 if it is impossible to make a square field.
Since the answer may be large, return it modulo 109 + 7.
Note: The field is surrounded by two horizontal fences from the coordinates (1, 1) to (1, n) and (m, 1) to (m, n) and two vertical fences from the coordinates (1, 1) to (m, 1) and (1, n) to (m, n). These fences cannot be removed.

Example 1:

Input: m = 4, n = 3, hFences = [2,3], vFences = [2]
Output: 4
Explanation: Removing the horizontal fence at 2 and the vertical fence at 2 will give a square field of area 4.

Example 2:

Input: m = 6, n = 7, hFences = [2], vFences = [4]
Output: -1
Explanation: It can be proved that there is no way to create a square field by removing fences.

Constraints:

3 <= m, n <= 109
1 <= hFences.length, vFences.length <= 600
1 < hFences[i] < m
1 < vFences[i] < n
hFences and vFences are unique.

Please complete the code below to solve above prblem:
```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:
"""
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i].
You start with the string source. In one operation, you can pick a character x from the string and change it to the character y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y.
Return the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.
Note that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].

Example 1:

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]
Output: 28
Explanation: To convert the string "abcd" to string "acbe":
- Change value at index 1 from 'b' to 'c' at a cost of 5.
- Change value at index 2 from 'c' to 'e' at a cost of 1.
- Change value at index 2 from 'e' to 'b' at a cost of 2.
- Change value at index 3 from 'd' to 'e' at a cost of 20.
The total cost incurred is 5 + 1 + 2 + 20 = 28.
It can be shown that this is the minimum possible cost.

Example 2:

Input: source = "aaaa", target = "bbbb", original = ["a","c"], changed = ["c","b"], cost = [1,2]
Output: 12
Explanation: To change the character 'a' to 'b' change the character 'a' to 'c' at a cost of 1, followed by changing the character 'c' to 'b' at a cost of 2, for a total cost of 1 + 2 = 3. To change all occurrences of 'a' to 'b', a total cost of 3 * 4 = 12 is incurred.

Example 3:

Input: source = "abcd", target = "abce", original = ["a"], changed = ["e"], cost = [10000]
Output: -1
Explanation: It is impossible to convert source to target because the value at index 3 cannot be changed from 'd' to 'e'.

Constraints:

1 <= source.length == target.length <= 105
source, target consist of lowercase English letters.
1 <= cost.length == original.length == changed.length <= 2000
original[i], changed[i] are lowercase English letters.
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:

You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i].
You start with the string source. In one operation, you can pick a character x from the string and change it to the character y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y.
Return the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.
Note that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].

Example 1:

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]
Output: 28
Explanation: To convert the string "abcd" to string "acbe":
- Change value at index 1 from 'b' to 'c' at a cost of 5.
- Change value at index 2 from 'c' to 'e' at a cost of 1.
- Change value at index 2 from 'e' to 'b' at a cost of 2.
- Change value at index 3 from 'd' to 'e' at a cost of 20.
The total cost incurred is 5 + 1 + 2 + 20 = 28.
It can be shown that this is the minimum possible cost.

Example 2:

Input: source = "aaaa", target = "bbbb", original = ["a","c"], changed = ["c","b"], cost = [1,2]
Output: 12
Explanation: To change the character 'a' to 'b' change the character 'a' to 'c' at a cost of 1, followed by changing the character 'c' to 'b' at a cost of 2, for a total cost of 1 + 2 = 3. To change all occurrences of 'a' to 'b', a total cost of 3 * 4 = 12 is incurred.

Example 3:

Input: source = "abcd", target = "abce", original = ["a"], changed = ["e"], cost = [10000]
Output: -1
Explanation: It is impossible to convert source to target because the value at index 3 cannot be changed from 'd' to 'e'.

Constraints:

1 <= source.length == target.length <= 105
source, target consist of lowercase English letters.
1 <= cost.length == original.length == changed.length <= 2000
original[i], changed[i] are lowercase English letters.
1 <= cost[i] <= 106
original[i] != changed[i]

Please complete the code below to solve above prblem:
```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:
"""
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English characters. You are also given two 0-indexed string arrays original and changed, and an integer array cost, where cost[i] represents the cost of converting the string original[i] to the string changed[i].
You start with the string source. In one operation, you can pick a substring x from the string, and change it to y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y. You are allowed to do any number of operations, but any pair of operations must satisfy either of these two conditions:

The substrings picked in the operations are source[a..b] and source[c..d] with either b < c or d < a. In other words, the indices picked in both operations are disjoint.
The substrings picked in the operations are source[a..b] and source[c..d] with a == c and b == d. In other words, the indices picked in both operations are identical.

Return the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.
Note that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].

Example 1:

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]
Output: 28
Explanation: To convert "abcd" to "acbe", do the following operations:
- Change substring source[1..1] from "b" to "c" at a cost of 5.
- Change substring source[2..2] from "c" to "e" at a cost of 1.
- Change substring source[2..2] from "e" to "b" at a cost of 2.
- Change substring source[3..3] from "d" to "e" at a cost of 20.
The total cost incurred is 5 + 1 + 2 + 20 = 28.
It can be shown that this is the minimum possible cost.

Example 2:

Input: source = "abcdefgh", target = "acdeeghh", original = ["bcd","fgh","thh"], changed = ["cde","thh","ghh"], cost = [1,3,5]
Output: 9
Explanation: To convert "abcdefgh" to "acdeeghh", do the following operations:
- Change substring source[1..3] from "bcd" to "cde" at a cost of 1.
- Change substring source[5..7] from "fgh" to "thh" at a cost of 3. We can do this operation because indices [5,7] are disjoint with indices picked in the first operation.
- Change substring source[5..7] from "thh" to "ghh" at a cost of 5. We can do this operation because indices [5,7] are disjoint with indices picked in the first operation, and identical with indices picked in the second operation.
The total cost incurred is 1 + 3 + 5 = 9.
It can be shown that this is the minimum possible cost.

Example 3:

Input: source = "abcdefgh", target = "addddddd", original = ["bcd","defgh"], changed = ["ddd","ddddd"], cost = [100,1578]
Output: -1
Explanation: It is impossible to convert "abcdefgh" to "addddddd".
If you select substring source[1..3] as the first operation to change "abcdefgh" to "adddefgh", you cannot select substring source[3..7] as the second operation because it has a common index, 3, with the first operation.
If you select substring source[3..7] as the first operation to change "abcdefgh" to "abcddddd", you cannot select substring source[1..3] as the second operation because it has a common index, 3, with the first operation.

Constraints:

1 <= source.length == target.length <= 1000
source, target consist only of lowercase English characters.
1 <= cost.length == original.length == changed.length <= 100
1 <= original[i].length == changed[i].length <= source.length
original[i], changed[i] consist only of lowercase English characters.
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:

You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English characters. You are also given two 0-indexed string arrays original and changed, and an integer array cost, where cost[i] represents the cost of converting the string original[i] to the string changed[i].
You start with the string source. In one operation, you can pick a substring x from the string, and change it to y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y. You are allowed to do any number of operations, but any pair of operations must satisfy either of these two conditions:

The substrings picked in the operations are source[a..b] and source[c..d] with either b < c or d < a. In other words, the indices picked in both operations are disjoint.
The substrings picked in the operations are source[a..b] and source[c..d] with a == c and b == d. In other words, the indices picked in both operations are identical.

Return the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.
Note that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].

Example 1:

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]
Output: 28
Explanation: To convert "abcd" to "acbe", do the following operations:
- Change substring source[1..1] from "b" to "c" at a cost of 5.
- Change substring source[2..2] from "c" to "e" at a cost of 1.
- Change substring source[2..2] from "e" to "b" at a cost of 2.
- Change substring source[3..3] from "d" to "e" at a cost of 20.
The total cost incurred is 5 + 1 + 2 + 20 = 28.
It can be shown that this is the minimum possible cost.

Example 2:

Input: source = "abcdefgh", target = "acdeeghh", original = ["bcd","fgh","thh"], changed = ["cde","thh","ghh"], cost = [1,3,5]
Output: 9
Explanation: To convert "abcdefgh" to "acdeeghh", do the following operations:
- Change substring source[1..3] from "bcd" to "cde" at a cost of 1.
- Change substring source[5..7] from "fgh" to "thh" at a cost of 3. We can do this operation because indices [5,7] are disjoint with indices picked in the first operation.
- Change substring source[5..7] from "thh" to "ghh" at a cost of 5. We can do this operation because indices [5,7] are disjoint with indices picked in the first operation, and identical with indices picked in the second operation.
The total cost incurred is 1 + 3 + 5 = 9.
It can be shown that this is the minimum possible cost.

Example 3:

Input: source = "abcdefgh", target = "addddddd", original = ["bcd","defgh"], changed = ["ddd","ddddd"], cost = [100,1578]
Output: -1
Explanation: It is impossible to convert "abcdefgh" to "addddddd".
If you select substring source[1..3] as the first operation to change "abcdefgh" to "adddefgh", you cannot select substring source[3..7] as the second operation because it has a common index, 3, with the first operation.
If you select substring source[3..7] as the first operation to change "abcdefgh" to "abcddddd", you cannot select substring source[1..3] as the second operation because it has a common index, 3, with the first operation.

Constraints:

1 <= source.length == target.length <= 1000
source, target consist only of lowercase English characters.
1 <= cost.length == original.length == changed.length <= 100
1 <= original[i].length == changed[i].length <= source.length
original[i], changed[i] consist only of lowercase English characters.
original[i] != changed[i]
1 <= cost[i] <= 106

Please complete the code below to solve above prblem:
```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:
"""
You are given a 0-indexed array of positive integers nums.
A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7] which is strictly increasing.
Return the total number of incremovable subarrays of nums.
Note that an empty array is considered strictly increasing.
A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [1,2,3,4]
Output: 10
Explanation: The 10 incremovable subarrays are: [1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4], and [1,2,3,4], because on removing any one of these subarrays nums becomes strictly increasing. Note that you cannot select an empty subarray.

Example 2:

Input: nums = [6,5,7,8]
Output: 7
Explanation: The 7 incremovable subarrays are: [5], [6], [5,7], [6,5], [5,7,8], [6,5,7] and [6,5,7,8].
It can be shown that there are only 7 incremovable subarrays in nums.

Example 3:

Input: nums = [8,7,6,6]
Output: 3
Explanation: The 3 incremovable subarrays are: [8,7,6], [7,6,6], and [8,7,6,6]. Note that [8,7] is not an incremovable subarray because after removing [8,7] nums becomes [6,6], which is sorted in ascending order but not strictly increasing.

Constraints:

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

You are given a 0-indexed array of positive integers nums.
A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7] which is strictly increasing.
Return the total number of incremovable subarrays of nums.
Note that an empty array is considered strictly increasing.
A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [1,2,3,4]
Output: 10
Explanation: The 10 incremovable subarrays are: [1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4], and [1,2,3,4], because on removing any one of these subarrays nums becomes strictly increasing. Note that you cannot select an empty subarray.

Example 2:

Input: nums = [6,5,7,8]
Output: 7
Explanation: The 7 incremovable subarrays are: [5], [6], [5,7], [6,5], [5,7,8], [6,5,7] and [6,5,7,8].
It can be shown that there are only 7 incremovable subarrays in nums.

Example 3:

Input: nums = [8,7,6,6]
Output: 3
Explanation: The 3 incremovable subarrays are: [8,7,6], [7,6,6], and [8,7,6,6]. Note that [8,7] is not an incremovable subarray because after removing [8,7] nums becomes [6,6], which is sorted in ascending order but not strictly increasing.

Constraints:

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

Please complete the code below to solve above prblem:
```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:
"""
You are given an array of positive integers nums of length n.
A polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is smaller than the sum of its other sides.
Conversely, if you have k (k >= 3) positive real numbers a1, a2, a3, ..., ak where a1 <= a2 <= a3 <= ... <= ak and a1 + a2 + a3 + ... + ak-1 > ak, then there always exists a polygon with k sides whose lengths are a1, a2, a3, ..., ak.
The perimeter of a polygon is the sum of lengths of its sides.
Return the largest possible perimeter of a polygon whose sides can be formed from nums, or -1 if it is not possible to create a polygon.

Example 1:

Input: nums = [5,5,5]
Output: 15
Explanation: The only possible polygon that can be made from nums has 3 sides: 5, 5, and 5. The perimeter is 5 + 5 + 5 = 15.

Example 2:

Input: nums = [1,12,1,2,5,50,3]
Output: 12
Explanation: The polygon with the largest perimeter which can be made from nums has 5 sides: 1, 1, 2, 3, and 5. The perimeter is 1 + 1 + 2 + 3 + 5 = 12.
We cannot have a polygon with either 12 or 50 as the longest side because it is not possible to include 2 or more smaller sides that have a greater sum than either of them.
It can be shown that the largest possible perimeter is 12.

Example 3:

Input: nums = [5,5,50]
Output: -1
Explanation: There is no possible way to form a polygon from nums, as a polygon has at least 3 sides and 50 > 5 + 5.

Constraints:

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

You are given an array of positive integers nums of length n.
A polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is smaller than the sum of its other sides.
Conversely, if you have k (k >= 3) positive real numbers a1, a2, a3, ..., ak where a1 <= a2 <= a3 <= ... <= ak and a1 + a2 + a3 + ... + ak-1 > ak, then there always exists a polygon with k sides whose lengths are a1, a2, a3, ..., ak.
The perimeter of a polygon is the sum of lengths of its sides.
Return the largest possible perimeter of a polygon whose sides can be formed from nums, or -1 if it is not possible to create a polygon.

Example 1:

Input: nums = [5,5,5]
Output: 15
Explanation: The only possible polygon that can be made from nums has 3 sides: 5, 5, and 5. The perimeter is 5 + 5 + 5 = 15.

Example 2:

Input: nums = [1,12,1,2,5,50,3]
Output: 12
Explanation: The polygon with the largest perimeter which can be made from nums has 5 sides: 1, 1, 2, 3, and 5. The perimeter is 1 + 1 + 2 + 3 + 5 = 12.
We cannot have a polygon with either 12 or 50 as the longest side because it is not possible to include 2 or more smaller sides that have a greater sum than either of them.
It can be shown that the largest possible perimeter is 12.

Example 3:

Input: nums = [5,5,50]
Output: -1
Explanation: There is no possible way to form a polygon from nums, as a polygon has at least 3 sides and 50 > 5 + 5.

Constraints:

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

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


count-the-number-of-incremovable-subarrays-ii

Count the Number of Incremovable Subarrays II

Prompt:
"""
You are given a 0-indexed array of positive integers nums.
A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7] which is strictly increasing.
Return the total number of incremovable subarrays of nums.
Note that an empty array is considered strictly increasing.
A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [1,2,3,4]
Output: 10
Explanation: The 10 incremovable subarrays are: [1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4], and [1,2,3,4], because on removing any one of these subarrays nums becomes strictly increasing. Note that you cannot select an empty subarray.

Example 2:

Input: nums = [6,5,7,8]
Output: 7
Explanation: The 7 incremovable subarrays are: [5], [6], [5,7], [6,5], [5,7,8], [6,5,7] and [6,5,7,8].
It can be shown that there are only 7 incremovable subarrays in nums.

Example 3:

Input: nums = [8,7,6,6]
Output: 3
Explanation: The 3 incremovable subarrays are: [8,7,6], [7,6,6], and [8,7,6,6]. Note that [8,7] is not an incremovable subarray because after removing [8,7] nums becomes [6,6], which is sorted in ascending order but not strictly increasing.

Constraints:

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

You are given a 0-indexed array of positive integers nums.
A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7] which is strictly increasing.
Return the total number of incremovable subarrays of nums.
Note that an empty array is considered strictly increasing.
A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [1,2,3,4]
Output: 10
Explanation: The 10 incremovable subarrays are: [1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4], and [1,2,3,4], because on removing any one of these subarrays nums becomes strictly increasing. Note that you cannot select an empty subarray.

Example 2:

Input: nums = [6,5,7,8]
Output: 7
Explanation: The 7 incremovable subarrays are: [5], [6], [5,7], [6,5], [5,7,8], [6,5,7] and [6,5,7,8].
It can be shown that there are only 7 incremovable subarrays in nums.

Example 3:

Input: nums = [8,7,6,6]
Output: 3
Explanation: The 3 incremovable subarrays are: [8,7,6], [7,6,6], and [8,7,6,6]. Note that [8,7] is not an incremovable subarray because after removing [8,7] nums becomes [6,6], which is sorted in ascending order but not strictly increasing.

Constraints:

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

Please complete the code below to solve above prblem:
```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": [4,10] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [11,50,14,33,45,38,33,19,28,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

test_input = { "nums": [25,9,28,31,38,15,31,44,46,49] }
assert my_solution.incremovableSubarrayCount(**test_input) == 11

test_input = { "nums": [25,26,49,31,40,47,30,29,32,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 13

test_input = { "nums": [25,39,29,30,40,28,30,39,30,42] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [25,41,31,38,30,38,37,41,36,32] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [25,45,49,28,47,44,42,34,28,25] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [25,46,48,41,29,47,32,34,41,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [25,47,25,35,48,49,27,37,36,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [26,26,50,38,30,38,31,26,39,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [26,32,41,38,45,32,31,27,48,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [26,45,44,26,33,35,34,36,44,38] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [26,49,42,26,37,41,31,36,45,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [27,39,32,30,38,41,28,26,49,49] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [27,43,36,37,33,46,48,35,49,49] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [28,17,12,21,21,49,31,30,40,13] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [28,30,39,31,33,41,47,36,43,46] }
assert my_solution.incremovableSubarrayCount(**test_input) == 15

test_input = { "nums": [29,27,32,38,26,38,39,30,41,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [29,31,48,28,27,38,32,28,30,44] }
assert my_solution.incremovableSubarrayCount(**test_input) == 10

test_input = { "nums": [29,34,44,27,45,31,37,32,50,26] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [29,38,36,42,31,38,27,48,42,28] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [29,46,34,47,46,41,29,29,38,39] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [29,49,32,35,38,37,27,25,50,46] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [30,27,38,33,28,48,41,30,25,50] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [30,29,31,44,31,25,50,35,35,47] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [30,30,46,35,31,41,30,37,37,33] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [30,41,28,45,35,41,47,32,29,33] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [30,45,44,27,43,40,28,34,39,40] }
assert my_solution.incremovableSubarrayCount(**test_input) == 10

test_input = { "nums": [30,49,34,26,50,50,48,49,39,26] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [31,34,25,43,38,34,29,50,27,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [31,35,39,38,41,47,26,43,47,46] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [31,37,29,41,32,46,25,28,30,29] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [31,38,31,47,25,25,36,29,43,28] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [31,41,25,37,43,29,30,26,30,46] }
assert my_solution.incremovableSubarrayCount(**test_input) == 8

test_input = { "nums": [31,42,40,36,39,28,43,29,35,50] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

test_input = { "nums": [32,29,13,39,34,47,38,15,10,5] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [32,35,32,50,32,26,29,49,40,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

test_input = { "nums": [32,37,35,26,45,44,47,29,31,28] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [32,43,44,44,36,41,31,33,41,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 11

test_input = { "nums": [32,50,50,46,32,30,32,32,31,39] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [33,27,34,46,42,35,36,49,25,40] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [33,28,35,32,36,38,33,47,36,35] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [33,31,36,38,39,46,42,41,27,33] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [33,45,25,48,45,42,35,38,47,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [33,46,38,37,42,48,31,43,38,29] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [33,48,50,48,46,33,34,26,32,33] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [34,25,38,41,31,46,40,46,39,30] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [34,38,35,28,30,37,35,25,48,28] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [34,47,26,48,30,25,26,43,44,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [35,22,35,6,20,47,3,29,45,30] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [35,25,29,40,32,29,35,39,39,32] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [35,26,39,41,26,44,36,26,46,50] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [35,27,29,45,29,30,48,42,37,50] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [35,31,27,45,39,46,47,49,26,27] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [35,39,36,30,32,48,34,25,37,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 9

test_input = { "nums": [36,26,44,32,36,29,44,28,48,30] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [36,28,28,45,40,40,32,48,34,48] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [36,28,34,49,48,36,50,25,43,40] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [36,30,47,32,32,35,41,49,41,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [36,31,45,34,47,48,49,31,34,34] }
assert my_solution.incremovableSubarrayCount(**test_input) == 3

test_input = { "nums": [37,33,50,48,25,37,29,49,46,45] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [37,35,29,27,39,38,49,48,27,37] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4

test_input = { "nums": [37,40,42,41,30,40,46,44,47,27] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [37,43,49,40,30,46,31,44,47,25] }
assert my_solution.incremovableSubarrayCount(**test_input) == 5

test_input = { "nums": [37,45,49,26,32,45,33,40,35,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [37,50,42,50,40,26,34,25,28,44] }
assert my_solution.incremovableSubarrayCount(**test_input) == 7

test_input = { "nums": [38,28,25,31,28,44,35,26,33,41] }
assert my_solution.incremovableSubarrayCount(**test_input) == 6

test_input = { "nums": [38,30,36,50,36,40,41,25,43,43] }
assert my_solution.incremovableSubarrayCount(**test_input) == 4


find-number-of-coins-to-place-in-tree-nodes

Find Number of Coins to Place in Tree Nodes

Prompt:
"""
You are given an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0. You are given a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.
You are also given a 0-indexed integer array cost of length n, where cost[i] is the cost assigned to the ith node.
You need to place some coins on every node of the tree. The number of coins to be placed at node i can be calculated as:

If size of the subtree of node i is less than 3, place 1 coin.
Otherwise, place an amount of coins equal to the maximum product of cost values assigned to 3 distinct nodes in the subtree of node i. If this product is negative, place 0 coins.

Return an array coin of size n such that coin[i] is the number of coins placed at node i.

Example 1:

Input: edges = [[0,1],[0,2],[0,3],[0,4],[0,5]], cost = [1,2,3,4,5,6]
Output: [120,1,1,1,1,1]
Explanation: For node 0 place 6 * 5 * 4 = 120 coins. All other nodes are leaves with subtree of size 1, place 1 coin on each of them.

Example 2:

Input: edges = [[0,1],[0,2],[1,3],[1,4],[1,5],[2,6],[2,7],[2,8]], cost = [1,4,2,3,5,7,8,-4,2]
Output: [280,140,32,1,1,1,1,1,1]
Explanation: The coins placed on each node are:
- Place 8 * 7 * 5 = 280 coins on node 0.
- Place 7 * 5 * 4 = 140 coins on node 1.
- Place 8 * 2 * 2 = 32 coins on node 2.
- All other nodes are leaves with subtree of size 1, place 1 coin on each of them.

Example 3:

Input: edges = [[0,1],[0,2]], cost = [1,2,-2]
Output: [0,1,1]
Explanation: Node 1 and 2 are leaves with subtree of size 1, place 1 coin on each of them. For node 0 the only possible product of cost is 2 * 1 * -2 = -4. Hence place 0 coins on node 0.

Constraints:

2 <= n <= 2 * 104
edges.length == n - 1
edges[i].length == 2
0 <= ai, bi < n
cost.length == n
1 <= |cost[i]| <= 104
The input is generated such that edges represents a valid tree.
"""
class Solution:
    def placedCoins(self, edges: List[List[int]], cost: List[int]) -> List[int]:

You are given an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0. You are given a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.
You are also given a 0-indexed integer array cost of length n, where cost[i] is the cost assigned to the ith node.
You need to place some coins on every node of the tree. The number of coins to be placed at node i can be calculated as:

If size of the subtree of node i is less than 3, place 1 coin.
Otherwise, place an amount of coins equal to the maximum product of cost values assigned to 3 distinct nodes in the subtree of node i. If this product is negative, place 0 coins.

Return an array coin of size n such that coin[i] is the number of coins placed at node i.

Example 1:

Input: edges = [[0,1],[0,2],[0,3],[0,4],[0,5]], cost = [1,2,3,4,5,6]
Output: [120,1,1,1,1,1]
Explanation: For node 0 place 6 * 5 * 4 = 120 coins. All other nodes are leaves with subtree of size 1, place 1 coin on each of them.

Example 2:

Input: edges = [[0,1],[0,2],[1,3],[1,4],[1,5],[2,6],[2,7],[2,8]], cost = [1,4,2,3,5,7,8,-4,2]
Output: [280,140,32,1,1,1,1,1,1]
Explanation: The coins placed on each node are:
- Place 8 * 7 * 5 = 280 coins on node 0.
- Place 7 * 5 * 4 = 140 coins on node 1.
- Place 8 * 2 * 2 = 32 coins on node 2.
- All other nodes are leaves with subtree of size 1, place 1 coin on each of them.

Example 3:

Input: edges = [[0,1],[0,2]], cost = [1,2,-2]
Output: [0,1,1]
Explanation: Node 1 and 2 are leaves with subtree of size 1, place 1 coin on each of them. For node 0 the only possible product of cost is 2 * 1 * -2 = -4. Hence place 0 coins on node 0.

Constraints:

2 <= n <= 2 * 104
edges.length == n - 1
edges[i].length == 2
0 <= ai, bi < n
cost.length == n
1 <= |cost[i]| <= 104
The input is generated such that edges represents a valid tree.

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

```