partition-string-into-minimum-beautiful-substrings

Partition String Into Minimum Beautiful Substrings

Prompt:
"""
Given a binary string s, partition the string into one or more substrings such that each substring is beautiful.

A string is beautiful if:

 * It doesn't contain leading zeros.
 * It's the binary representation of a number that is a power of 5.

Return the minimum number of substrings in such partition. If it is impossible to partition the string s into beautiful substrings, return -1.

A substring is a contiguous sequence of characters in a string.

Example 1:

Input: s = "1011"
Output: 2
Explanation: We can paritition the given string into ["101", "1"].
- The string "101" does not contain leading zeros and is the binary representation of integer 51 = 5.
- The string "1" does not contain leading zeros and is the binary representation of integer 50 = 1.
It can be shown that 2 is the minimum number of beautiful substrings that s can be partitioned into.

Example 2:

Input: s = "111"
Output: 3
Explanation: We can paritition the given string into ["1", "1", "1"].
- The string "1" does not contain leading zeros and is the binary representation of integer 50 = 1.
It can be shown that 3 is the minimum number of beautiful substrings that s can be partitioned into.

Example 3:

Input: s = "0"
Output: -1
Explanation: We can not partition the given string into beautiful substrings.

Constraints:

 * 1 <= s.length <= 15
 * s[i] is either '0' or '1'.
"""
class Solution:
    def minimumBeautifulSubstrings(self, s: str) -> int:

Given a binary string s, partition the string into one or more substrings such that each substring is beautiful.

A string is beautiful if:

 * It doesn't contain leading zeros.
 * It's the binary representation of a number that is a power of 5.

Return the minimum number of substrings in such partition. If it is impossible to partition the string s into beautiful substrings, return -1.

A substring is a contiguous sequence of characters in a string.

Example 1:

Input: s = "1011"
Output: 2
Explanation: We can paritition the given string into ["101", "1"].
- The string "101" does not contain leading zeros and is the binary representation of integer 51 = 5.
- The string "1" does not contain leading zeros and is the binary representation of integer 50 = 1.
It can be shown that 2 is the minimum number of beautiful substrings that s can be partitioned into.

Example 2:

Input: s = "111"
Output: 3
Explanation: We can paritition the given string into ["1", "1", "1"].
- The string "1" does not contain leading zeros and is the binary representation of integer 50 = 1.
It can be shown that 3 is the minimum number of beautiful substrings that s can be partitioned into.

Example 3:

Input: s = "0"
Output: -1
Explanation: We can not partition the given string into beautiful substrings.

Constraints:

 * 1 <= s.length <= 15
 * s[i] is either '0' or '1'.

Please complete the code below to solve above prblem:
```python
class Solution:
    def minimumBeautifulSubstrings(self, s: str) -> int:

```

my_solution = Solution()

test_input = { "s": "1011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 2

test_input = { "s": "111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "0" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == -1

test_input = { "s": "100111000110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "100111000111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "1001110001111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "100111000111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10110011100011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 2

test_input = { "s": "101101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "101101101101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "1011011011101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10110110111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101101101111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "1011011011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101101110011101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10110111001111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011011101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101101110110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101101110111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011011101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101101110111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10110111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101101111001101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10110111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10110111101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101101111011011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101101111011101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10110111101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101101111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "1011011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011011111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101101111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011011111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10110111110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "10110111111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101101111110011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10110111111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "101101111110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101101111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101101111111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101110011011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10111001101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "101110011011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011100111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10111001110001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "10111001110011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "1011100111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111001110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "10111001111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111001111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "1011100111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101110011110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101110011111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111001111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101110011111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011100111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111001111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "1011101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10111011011011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101110110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101110110111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011101101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101110111001101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101110111001111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111011101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111011101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101110111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "1011101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011101111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111011110011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101110111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011101111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111011111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "10111011111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101110111110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "101110111111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101110111111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101110111111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111011111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 10

test_input = { "s": "101110111111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 11

test_input = { "s": "101111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "101111001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 3

test_input = { "s": "1011110011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "10111100110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "101111001110001" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 4

test_input = { "s": "101111001111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "10111100111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "101111011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "101111011011" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "10111101101101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 6

test_input = { "s": "1011110110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "1011110111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 7

test_input = { "s": "101111011110111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "101111011111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 8

test_input = { "s": "1011110111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 9

test_input = { "s": "101111011111101" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 5

test_input = { "s": "10111101111111" }
assert my_solution.minimumBeautifulSubstrings(**test_input) == 10


number-of-black-blocks

Number of Black Blocks

Prompt:
"""
You are given two integers m and n representing the dimensions of a 0-indexed m x n grid.

You are also given a 0-indexed 2D integer matrix coordinates, where coordinates[i] = [x, y] indicates that the cell with coordinates [x, y] is colored black. All cells in the grid that do not appear in coordinates are white.

A block is defined as a 2 x 2 submatrix of the grid. More formally, a block with cell [x, y] as its top-left corner where 0 <= x < m - 1 and 0 <= y < n - 1 contains the coordinates [x, y], [x + 1, y], [x, y + 1], and [x + 1, y + 1].

Return a 0-indexed integer array arr of size 5 such that arr[i] is the number of blocks that contains exactly i black cells.

Example 1:

Input: m = 3, n = 3, coordinates = [[0,0]]
Output: [3,1,0,0,0]
Explanation: The grid looks like this:
[https://assets.leetcode.com/uploads/2023/06/18/screen-shot-2023-06-18-at-44656-am.png]
There is only 1 block with one black cell, and it is the block starting with cell [0,0].
The other 3 blocks start with cells [0,1], [1,0] and [1,1]. They all have zero black cells.
Thus, we return [3,1,0,0,0].

Example 2:

Input: m = 3, n = 3, coordinates = [[0,0],[1,1],[0,2]]
Output: [0,2,2,0,0]
Explanation: The grid looks like this:
[https://assets.leetcode.com/uploads/2023/06/18/screen-shot-2023-06-18-at-45018-am.png]
There are 2 blocks with two black cells (the ones starting with cell coordinates [0,0] and [0,1]).
The other 2 blocks have starting cell coordinates of [1,0] and [1,1]. They both have 1 black cell.
Therefore, we return [0,2,2,0,0].

Constraints:

 * 2 <= m <= 105
 * 2 <= n <= 105
 * 0 <= coordinates.length <= 104
 * coordinates[i].length == 2
 * 0 <= coordinates[i][0] < m
 * 0 <= coordinates[i][1] < n
 * It is guaranteed that coordinates contains pairwise distinct coordinates.
"""
class Solution:
    def countBlackBlocks(self, m: int, n: int, coordinates: List[List[int]]) -> List[int]:

You are given two integers m and n representing the dimensions of a 0-indexed m x n grid.

You are also given a 0-indexed 2D integer matrix coordinates, where coordinates[i] = [x, y] indicates that the cell with coordinates [x, y] is colored black. All cells in the grid that do not appear in coordinates are white.

A block is defined as a 2 x 2 submatrix of the grid. More formally, a block with cell [x, y] as its top-left corner where 0 <= x < m - 1 and 0 <= y < n - 1 contains the coordinates [x, y], [x + 1, y], [x, y + 1], and [x + 1, y + 1].

Return a 0-indexed integer array arr of size 5 such that arr[i] is the number of blocks that contains exactly i black cells.

Example 1:

Input: m = 3, n = 3, coordinates = [[0,0]]
Output: [3,1,0,0,0]
Explanation: The grid looks like this:
[https://assets.leetcode.com/uploads/2023/06/18/screen-shot-2023-06-18-at-44656-am.png]
There is only 1 block with one black cell, and it is the block starting with cell [0,0].
The other 3 blocks start with cells [0,1], [1,0] and [1,1]. They all have zero black cells.
Thus, we return [3,1,0,0,0].

Example 2:

Input: m = 3, n = 3, coordinates = [[0,0],[1,1],[0,2]]
Output: [0,2,2,0,0]
Explanation: The grid looks like this:
[https://assets.leetcode.com/uploads/2023/06/18/screen-shot-2023-06-18-at-45018-am.png]
There are 2 blocks with two black cells (the ones starting with cell coordinates [0,0] and [0,1]).
The other 2 blocks have starting cell coordinates of [1,0] and [1,1]. They both have 1 black cell.
Therefore, we return [0,2,2,0,0].

Constraints:

 * 2 <= m <= 105
 * 2 <= n <= 105
 * 0 <= coordinates.length <= 104
 * coordinates[i].length == 2
 * 0 <= coordinates[i][0] < m
 * 0 <= coordinates[i][1] < n
 * It is guaranteed that coordinates contains pairwise distinct coordinates.

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

```


longest-even-odd-subarray-with-threshold

Longest Even Odd Subarray With Threshold

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

Find the length of the longest subarray of nums starting at index l and ending at index r (0 <= l <= r < nums.length) that satisfies the following conditions:

 * nums[l] % 2 == 0
 * For all indices i in the range [l, r - 1], nums[i] % 2 != nums[i + 1] % 2
 * For all indices i in the range [l, r], nums[i] <= threshold

Return an integer denoting the length of the longest such subarray.

Note: A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [3,2,5,4], threshold = 5
Output: 3
Explanation: In this example, we can select the subarray that starts at l = 1 and ends at r = 3 => [2,5,4]. This subarray satisfies the conditions.
Hence, the answer is the length of the subarray, 3. We can show that 3 is the maximum possible achievable length.

Example 2:

Input: nums = [1,2], threshold = 2
Output: 1
Explanation: In this example, we can select the subarray that starts at l = 1 and ends at r = 1 => [2].
It satisfies all the conditions and we can show that 1 is the maximum possible achievable length.

Example 3:

Input: nums = [2,3,4,5], threshold = 4
Output: 3
Explanation: In this example, we can select the subarray that starts at l = 0 and ends at r = 2 => [2,3,4].
It satisfies all the conditions.
Hence, the answer is the length of the subarray, 3. We can show that 3 is the maximum possible achievable length.

Constraints:

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

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

Find the length of the longest subarray of nums starting at index l and ending at index r (0 <= l <= r < nums.length) that satisfies the following conditions:

 * nums[l] % 2 == 0
 * For all indices i in the range [l, r - 1], nums[i] % 2 != nums[i + 1] % 2
 * For all indices i in the range [l, r], nums[i] <= threshold

Return an integer denoting the length of the longest such subarray.

Note: A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [3,2,5,4], threshold = 5
Output: 3
Explanation: In this example, we can select the subarray that starts at l = 1 and ends at r = 3 => [2,5,4]. This subarray satisfies the conditions.
Hence, the answer is the length of the subarray, 3. We can show that 3 is the maximum possible achievable length.

Example 2:

Input: nums = [1,2], threshold = 2
Output: 1
Explanation: In this example, we can select the subarray that starts at l = 1 and ends at r = 1 => [2].
It satisfies all the conditions and we can show that 1 is the maximum possible achievable length.

Example 3:

Input: nums = [2,3,4,5], threshold = 4
Output: 3
Explanation: In this example, we can select the subarray that starts at l = 0 and ends at r = 2 => [2,3,4].
It satisfies all the conditions.
Hence, the answer is the length of the subarray, 3. We can show that 3 is the maximum possible achievable length.

Constraints:

 * 1 <= nums.length <= 100
 * 1 <= nums[i] <= 100
 * 1 <= threshold <= 100

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

```

my_solution = Solution()

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

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

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

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

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

test_input = { "nums": [3], "threshold": 3 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [4], "threshold": 1 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [5], "threshold": 3 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

test_input = { "nums": [7], "threshold": 2 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [8], "threshold": 1 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [9], "threshold": 7 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [10], "threshold": 7 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [1,3], "threshold": 16 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

test_input = { "nums": [1,10], "threshold": 6 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [1,10], "threshold": 7 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

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

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

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

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

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

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

test_input = { "nums": [2,8], "threshold": 16 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [2,9], "threshold": 14 }
assert my_solution.longestAlternatingSubarray(**test_input) == 2

test_input = { "nums": [3,1], "threshold": 9 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

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

test_input = { "nums": [4,2], "threshold": 11 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

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

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

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

test_input = { "nums": [4,9], "threshold": 17 }
assert my_solution.longestAlternatingSubarray(**test_input) == 2

test_input = { "nums": [5,8], "threshold": 5 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [5,8], "threshold": 15 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

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

test_input = { "nums": [6,4], "threshold": 14 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [6,4], "threshold": 16 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

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

test_input = { "nums": [7,3], "threshold": 8 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

test_input = { "nums": [7,5], "threshold": 1 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [7,10], "threshold": 52 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [7,17], "threshold": 31 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [8,4], "threshold": 6 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [8,8], "threshold": 20 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [9,2], "threshold": 11 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

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

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

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

test_input = { "nums": [10,5], "threshold": 20 }
assert my_solution.longestAlternatingSubarray(**test_input) == 2

test_input = { "nums": [10,7], "threshold": 11 }
assert my_solution.longestAlternatingSubarray(**test_input) == 2

test_input = { "nums": [10,8], "threshold": 4 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [10,18], "threshold": 43 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [12,34], "threshold": 7 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [12,35], "threshold": 8 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [13,9], "threshold": 53 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [15,13], "threshold": 23 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [15,15], "threshold": 18 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

test_input = { "nums": [23,37], "threshold": 35 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [24,11], "threshold": 54 }
assert my_solution.longestAlternatingSubarray(**test_input) == 2

test_input = { "nums": [27,9], "threshold": 55 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [27,17], "threshold": 40 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [33,4], "threshold": 43 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

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

test_input = { "nums": [47,44], "threshold": 20 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [49,39], "threshold": 52 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [50,8], "threshold": 19 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [76,46], "threshold": 91 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [1,1,7], "threshold": 4 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [1,3,1], "threshold": 18 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

test_input = { "nums": [1,5,3], "threshold": 8 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [1,10,5], "threshold": 9 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

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

test_input = { "nums": [3,2,8], "threshold": 18 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [3,3,10], "threshold": 20 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

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

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

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

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

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

test_input = { "nums": [4,5,10], "threshold": 3 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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

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

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

test_input = { "nums": [4,40,8], "threshold": 45 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

test_input = { "nums": [5,3,9], "threshold": 7 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

test_input = { "nums": [5,5,6], "threshold": 7 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

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

test_input = { "nums": [6,2,4], "threshold": 17 }
assert my_solution.longestAlternatingSubarray(**test_input) == 1

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

test_input = { "nums": [6,5,2], "threshold": 17 }
assert my_solution.longestAlternatingSubarray(**test_input) == 3

test_input = { "nums": [6,5,3], "threshold": 17 }
assert my_solution.longestAlternatingSubarray(**test_input) == 2

test_input = { "nums": [6,7,2], "threshold": 14 }
assert my_solution.longestAlternatingSubarray(**test_input) == 3

test_input = { "nums": [7,1,10], "threshold": 9 }
assert my_solution.longestAlternatingSubarray(**test_input) == 0

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


prime-pairs-with-target-sum

Prime Pairs With Target Sum

Prompt:
"""
You are given an integer n. We say that two integers x and y form a prime number pair if:

 * 1 <= x <= y <= n
 * x + y == n
 * x and y are prime numbers

Return the 2D sorted list of prime number pairs [xi, yi]. The list should be sorted in increasing order of xi. If there are no prime number pairs at all, return an empty array.

Note: A prime number is a natural number greater than 1 with only two factors, itself and 1.

Example 1:

Input: n = 10
Output: [[3,7],[5,5]]
Explanation: In this example, there are two prime pairs that satisfy the criteria.
These pairs are [3,7] and [5,5], and we return them in the sorted order as described in the problem statement.

Example 2:

Input: n = 2
Output: []
Explanation: We can show that there is no prime number pair that gives a sum of 2, so we return an empty array.

Constraints:

 * 1 <= n <= 106
"""
class Solution:
    def findPrimePairs(self, n: int) -> List[List[int]]:

You are given an integer n. We say that two integers x and y form a prime number pair if:

 * 1 <= x <= y <= n
 * x + y == n
 * x and y are prime numbers

Return the 2D sorted list of prime number pairs [xi, yi]. The list should be sorted in increasing order of xi. If there are no prime number pairs at all, return an empty array.

Note: A prime number is a natural number greater than 1 with only two factors, itself and 1.

Example 1:

Input: n = 10
Output: [[3,7],[5,5]]
Explanation: In this example, there are two prime pairs that satisfy the criteria.
These pairs are [3,7] and [5,5], and we return them in the sorted order as described in the problem statement.

Example 2:

Input: n = 2
Output: []
Explanation: We can show that there is no prime number pair that gives a sum of 2, so we return an empty array.

Constraints:

 * 1 <= n <= 106

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

```

my_solution = Solution()

test_input = { "n": 10 }
assert my_solution.findPrimePairs(**test_input) == [[3,7],[5,5]]

test_input = { "n": 2 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 1 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 3 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 4 }
assert my_solution.findPrimePairs(**test_input) == [[2,2]]

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

test_input = { "n": 6 }
assert my_solution.findPrimePairs(**test_input) == [[3,3]]

test_input = { "n": 7 }
assert my_solution.findPrimePairs(**test_input) == [[2,5]]

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

test_input = { "n": 9 }
assert my_solution.findPrimePairs(**test_input) == [[2,7]]

test_input = { "n": 11 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 12 }
assert my_solution.findPrimePairs(**test_input) == [[5,7]]

test_input = { "n": 13 }
assert my_solution.findPrimePairs(**test_input) == [[2,11]]

test_input = { "n": 14 }
assert my_solution.findPrimePairs(**test_input) == [[3,11],[7,7]]

test_input = { "n": 15 }
assert my_solution.findPrimePairs(**test_input) == [[2,13]]

test_input = { "n": 16 }
assert my_solution.findPrimePairs(**test_input) == [[3,13],[5,11]]

test_input = { "n": 17 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 18 }
assert my_solution.findPrimePairs(**test_input) == [[5,13],[7,11]]

test_input = { "n": 19 }
assert my_solution.findPrimePairs(**test_input) == [[2,17]]

test_input = { "n": 20 }
assert my_solution.findPrimePairs(**test_input) == [[3,17],[7,13]]

test_input = { "n": 21 }
assert my_solution.findPrimePairs(**test_input) == [[2,19]]

test_input = { "n": 22 }
assert my_solution.findPrimePairs(**test_input) == [[3,19],[5,17],[11,11]]

test_input = { "n": 23 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 24 }
assert my_solution.findPrimePairs(**test_input) == [[5,19],[7,17],[11,13]]

test_input = { "n": 25 }
assert my_solution.findPrimePairs(**test_input) == [[2,23]]

test_input = { "n": 26 }
assert my_solution.findPrimePairs(**test_input) == [[3,23],[7,19],[13,13]]

test_input = { "n": 27 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 28 }
assert my_solution.findPrimePairs(**test_input) == [[5,23],[11,17]]

test_input = { "n": 29 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 30 }
assert my_solution.findPrimePairs(**test_input) == [[7,23],[11,19],[13,17]]

test_input = { "n": 31 }
assert my_solution.findPrimePairs(**test_input) == [[2,29]]

test_input = { "n": 32 }
assert my_solution.findPrimePairs(**test_input) == [[3,29],[13,19]]

test_input = { "n": 33 }
assert my_solution.findPrimePairs(**test_input) == [[2,31]]

test_input = { "n": 34 }
assert my_solution.findPrimePairs(**test_input) == [[3,31],[5,29],[11,23],[17,17]]

test_input = { "n": 35 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 36 }
assert my_solution.findPrimePairs(**test_input) == [[5,31],[7,29],[13,23],[17,19]]

test_input = { "n": 37 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 38 }
assert my_solution.findPrimePairs(**test_input) == [[7,31],[19,19]]

test_input = { "n": 39 }
assert my_solution.findPrimePairs(**test_input) == [[2,37]]

test_input = { "n": 40 }
assert my_solution.findPrimePairs(**test_input) == [[3,37],[11,29],[17,23]]

test_input = { "n": 41 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 42 }
assert my_solution.findPrimePairs(**test_input) == [[5,37],[11,31],[13,29],[19,23]]

test_input = { "n": 43 }
assert my_solution.findPrimePairs(**test_input) == [[2,41]]

test_input = { "n": 44 }
assert my_solution.findPrimePairs(**test_input) == [[3,41],[7,37],[13,31]]

test_input = { "n": 45 }
assert my_solution.findPrimePairs(**test_input) == [[2,43]]

test_input = { "n": 46 }
assert my_solution.findPrimePairs(**test_input) == [[3,43],[5,41],[17,29],[23,23]]

test_input = { "n": 47 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 48 }
assert my_solution.findPrimePairs(**test_input) == [[5,43],[7,41],[11,37],[17,31],[19,29]]

test_input = { "n": 49 }
assert my_solution.findPrimePairs(**test_input) == [[2,47]]

test_input = { "n": 50 }
assert my_solution.findPrimePairs(**test_input) == [[3,47],[7,43],[13,37],[19,31]]

test_input = { "n": 51 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 52 }
assert my_solution.findPrimePairs(**test_input) == [[5,47],[11,41],[23,29]]

test_input = { "n": 53 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 54 }
assert my_solution.findPrimePairs(**test_input) == [[7,47],[11,43],[13,41],[17,37],[23,31]]

test_input = { "n": 55 }
assert my_solution.findPrimePairs(**test_input) == [[2,53]]

test_input = { "n": 56 }
assert my_solution.findPrimePairs(**test_input) == [[3,53],[13,43],[19,37]]

test_input = { "n": 57 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 58 }
assert my_solution.findPrimePairs(**test_input) == [[5,53],[11,47],[17,41],[29,29]]

test_input = { "n": 59 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 60 }
assert my_solution.findPrimePairs(**test_input) == [[7,53],[13,47],[17,43],[19,41],[23,37],[29,31]]

test_input = { "n": 61 }
assert my_solution.findPrimePairs(**test_input) == [[2,59]]

test_input = { "n": 62 }
assert my_solution.findPrimePairs(**test_input) == [[3,59],[19,43],[31,31]]

test_input = { "n": 63 }
assert my_solution.findPrimePairs(**test_input) == [[2,61]]

test_input = { "n": 64 }
assert my_solution.findPrimePairs(**test_input) == [[3,61],[5,59],[11,53],[17,47],[23,41]]

test_input = { "n": 65 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 66 }
assert my_solution.findPrimePairs(**test_input) == [[5,61],[7,59],[13,53],[19,47],[23,43],[29,37]]

test_input = { "n": 67 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 68 }
assert my_solution.findPrimePairs(**test_input) == [[7,61],[31,37]]

test_input = { "n": 69 }
assert my_solution.findPrimePairs(**test_input) == [[2,67]]

test_input = { "n": 70 }
assert my_solution.findPrimePairs(**test_input) == [[3,67],[11,59],[17,53],[23,47],[29,41]]

test_input = { "n": 71 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 72 }
assert my_solution.findPrimePairs(**test_input) == [[5,67],[11,61],[13,59],[19,53],[29,43],[31,41]]

test_input = { "n": 73 }
assert my_solution.findPrimePairs(**test_input) == [[2,71]]

test_input = { "n": 74 }
assert my_solution.findPrimePairs(**test_input) == [[3,71],[7,67],[13,61],[31,43],[37,37]]

test_input = { "n": 75 }
assert my_solution.findPrimePairs(**test_input) == [[2,73]]

test_input = { "n": 76 }
assert my_solution.findPrimePairs(**test_input) == [[3,73],[5,71],[17,59],[23,53],[29,47]]

test_input = { "n": 77 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 78 }
assert my_solution.findPrimePairs(**test_input) == [[5,73],[7,71],[11,67],[17,61],[19,59],[31,47],[37,41]]

test_input = { "n": 79 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 80 }
assert my_solution.findPrimePairs(**test_input) == [[7,73],[13,67],[19,61],[37,43]]

test_input = { "n": 81 }
assert my_solution.findPrimePairs(**test_input) == [[2,79]]

test_input = { "n": 82 }
assert my_solution.findPrimePairs(**test_input) == [[3,79],[11,71],[23,59],[29,53],[41,41]]

test_input = { "n": 83 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 84 }
assert my_solution.findPrimePairs(**test_input) == [[5,79],[11,73],[13,71],[17,67],[23,61],[31,53],[37,47],[41,43]]

test_input = { "n": 85 }
assert my_solution.findPrimePairs(**test_input) == [[2,83]]

test_input = { "n": 86 }
assert my_solution.findPrimePairs(**test_input) == [[3,83],[7,79],[13,73],[19,67],[43,43]]

test_input = { "n": 87 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 88 }
assert my_solution.findPrimePairs(**test_input) == [[5,83],[17,71],[29,59],[41,47]]

test_input = { "n": 89 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 90 }
assert my_solution.findPrimePairs(**test_input) == [[7,83],[11,79],[17,73],[19,71],[23,67],[29,61],[31,59],[37,53],[43,47]]

test_input = { "n": 91 }
assert my_solution.findPrimePairs(**test_input) == [[2,89]]

test_input = { "n": 92 }
assert my_solution.findPrimePairs(**test_input) == [[3,89],[13,79],[19,73],[31,61]]

test_input = { "n": 93 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 94 }
assert my_solution.findPrimePairs(**test_input) == [[5,89],[11,83],[23,71],[41,53],[47,47]]

test_input = { "n": 95 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 96 }
assert my_solution.findPrimePairs(**test_input) == [[7,89],[13,83],[17,79],[23,73],[29,67],[37,59],[43,53]]

test_input = { "n": 97 }
assert my_solution.findPrimePairs(**test_input) == []

test_input = { "n": 98 }
assert my_solution.findPrimePairs(**test_input) == [[19,79],[31,67],[37,61]]

test_input = { "n": 99 }
assert my_solution.findPrimePairs(**test_input) == [[2,97]]

test_input = { "n": 100 }
assert my_solution.findPrimePairs(**test_input) == [[3,97],[11,89],[17,83],[29,71],[41,59],[47,53]]


continuous-subarrays

Continuous Subarrays

Prompt:
"""
You are given a 0-indexed integer array nums. A subarray of nums is called continuous if:

 * Let i, i + 1, ..., j be the indices in the subarray. Then, for each pair of indices i <= i1, i2 <= j, 0 <= |nums[i1] - nums[i2]| <= 2.

Return the total number of continuous subarrays.

A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [5,4,2,4]
Output: 8
Explanation:
Continuous subarray of size 1: [5], [4], [2], [4].
Continuous subarray of size 2: [5,4], [4,2], [2,4].
Continuous subarray of size 3: [4,2,4].
Thereare no subarrys of size 4.
Total continuous subarrays = 4 + 3 + 1 = 8.
It can be shown that there are no more continuous subarrays.

Example 2:

Input: nums = [1,2,3]
Output: 6
Explanation:
Continuous subarray of size 1: [1], [2], [3].
Continuous subarray of size 2: [1,2], [2,3].
Continuous subarray of size 3: [1,2,3].
Total continuous subarrays = 3 + 2 + 1 = 6.

Constraints:

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

You are given a 0-indexed integer array nums. A subarray of nums is called continuous if:

 * Let i, i + 1, ..., j be the indices in the subarray. Then, for each pair of indices i <= i1, i2 <= j, 0 <= |nums[i1] - nums[i2]| <= 2.

Return the total number of continuous subarrays.

A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [5,4,2,4]
Output: 8
Explanation:
Continuous subarray of size 1: [5], [4], [2], [4].
Continuous subarray of size 2: [5,4], [4,2], [2,4].
Continuous subarray of size 3: [4,2,4].
Thereare no subarrys of size 4.
Total continuous subarrays = 4 + 3 + 1 = 8.
It can be shown that there are no more continuous subarrays.

Example 2:

Input: nums = [1,2,3]
Output: 6
Explanation:
Continuous subarray of size 1: [1], [2], [3].
Continuous subarray of size 2: [1,2], [2,3].
Continuous subarray of size 3: [1,2,3].
Total continuous subarrays = 3 + 2 + 1 = 6.

Constraints:

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

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

```

my_solution = Solution()

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

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

test_input = { "nums": [31,30,31,32] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [65,66,67,66,66,65,64,65,65,64] }
assert my_solution.continuousSubarrays(**test_input) == 43

test_input = { "nums": [42,41,42,41,41,40,39,38] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [35,35,36,37,36,37,38,37,38] }
assert my_solution.continuousSubarrays(**test_input) == 39

test_input = { "nums": [43,44,43,44] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [14,15,15,15,16,16,16,16,15,16] }
assert my_solution.continuousSubarrays(**test_input) == 55

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

test_input = { "nums": [34,34,33,34,33,33,32,31,30,31] }
assert my_solution.continuousSubarrays(**test_input) == 39

test_input = { "nums": [58,59,59,58,59] }
assert my_solution.continuousSubarrays(**test_input) == 15

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

test_input = { "nums": [65,66,65,64,63,62,62] }
assert my_solution.continuousSubarrays(**test_input) == 20

test_input = { "nums": [65,65,64,65,66,65] }
assert my_solution.continuousSubarrays(**test_input) == 21

test_input = { "nums": [85,84,83,84,83,82] }
assert my_solution.continuousSubarrays(**test_input) == 20

test_input = { "nums": [60,59,60] }
assert my_solution.continuousSubarrays(**test_input) == 6

test_input = { "nums": [96,97,98] }
assert my_solution.continuousSubarrays(**test_input) == 6

test_input = { "nums": [21,22,23,22,23] }
assert my_solution.continuousSubarrays(**test_input) == 15

test_input = { "nums": [76,77,77,78,77,78,78] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [27,27,27,26,26,27,27,27,27] }
assert my_solution.continuousSubarrays(**test_input) == 45

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

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

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

test_input = { "nums": [10,10,9,8,9,9,9,8,8] }
assert my_solution.continuousSubarrays(**test_input) == 45

test_input = { "nums": [21,22,22,23,24,24,23,24,23,24] }
assert my_solution.continuousSubarrays(**test_input) == 49

test_input = { "nums": [94,94,94,94,94,93,94] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [66,65,64,64,64,65,64,63] }
assert my_solution.continuousSubarrays(**test_input) == 35

test_input = { "nums": [35,35,36,36,35] }
assert my_solution.continuousSubarrays(**test_input) == 15

test_input = { "nums": [35,34,33,34,35,35,34,35,34] }
assert my_solution.continuousSubarrays(**test_input) == 45

test_input = { "nums": [70,69,70,71,70,70,71,71] }
assert my_solution.continuousSubarrays(**test_input) == 36

test_input = { "nums": [49,49,49,50,50,49,50,51,51] }
assert my_solution.continuousSubarrays(**test_input) == 45

test_input = { "nums": [70,71,72,72,72] }
assert my_solution.continuousSubarrays(**test_input) == 15

test_input = { "nums": [73,73,74,75,76,76,75,76] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [74,74,74,75,76,75,75,76,77,77] }
assert my_solution.continuousSubarrays(**test_input) == 49

test_input = { "nums": [21,21,20,19,20,20,21,21] }
assert my_solution.continuousSubarrays(**test_input) == 36

test_input = { "nums": [86,85] }
assert my_solution.continuousSubarrays(**test_input) == 3

test_input = { "nums": [94,95,96,96,97,98,99,100,100] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [16,17,16] }
assert my_solution.continuousSubarrays(**test_input) == 6

test_input = { "nums": [25,26,26,27,28,27,28,28,27,27] }
assert my_solution.continuousSubarrays(**test_input) == 49

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

test_input = { "nums": [94,95,96,95,94,93,92,91] }
assert my_solution.continuousSubarrays(**test_input) == 24

test_input = { "nums": [84,84,83] }
assert my_solution.continuousSubarrays(**test_input) == 6

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

test_input = { "nums": [53,54,54,55] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [67,67,66,67,68,69,70,71,71] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [43,42,42,42,43] }
assert my_solution.continuousSubarrays(**test_input) == 15

test_input = { "nums": [93,94,93] }
assert my_solution.continuousSubarrays(**test_input) == 6

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

test_input = { "nums": [54,54,53,54,55,56,57,58,59] }
assert my_solution.continuousSubarrays(**test_input) == 27

test_input = { "nums": [52,51,50,49,48,49,48,47,46] }
assert my_solution.continuousSubarrays(**test_input) == 29

test_input = { "nums": [93,92,91,92,92,92,92] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [91,91,90,90,90,91,91,90] }
assert my_solution.continuousSubarrays(**test_input) == 36

test_input = { "nums": [37,37,37,36] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [40,39,39,39,39,40,40,41,40,39] }
assert my_solution.continuousSubarrays(**test_input) == 55

test_input = { "nums": [82,83,83,83,83,84] }
assert my_solution.continuousSubarrays(**test_input) == 21

test_input = { "nums": [35,36,36,37,37,37,36,37,36] }
assert my_solution.continuousSubarrays(**test_input) == 45

test_input = { "nums": [50,49,50,51,50] }
assert my_solution.continuousSubarrays(**test_input) == 15

test_input = { "nums": [86,86,86,86,87] }
assert my_solution.continuousSubarrays(**test_input) == 15

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

test_input = { "nums": [96,95,94,93] }
assert my_solution.continuousSubarrays(**test_input) == 9

test_input = { "nums": [56,56,55,55,54,55,54,54,53,52] }
assert my_solution.continuousSubarrays(**test_input) == 47

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

test_input = { "nums": [91,90,91,91] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [56,55,55,55] }
assert my_solution.continuousSubarrays(**test_input) == 10

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

test_input = { "nums": [84,85,84,84,85,85,85] }
assert my_solution.continuousSubarrays(**test_input) == 28

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

test_input = { "nums": [47,47,46] }
assert my_solution.continuousSubarrays(**test_input) == 6

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

test_input = { "nums": [20,20,19,18] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [22,23,23,22,22,22,22] }
assert my_solution.continuousSubarrays(**test_input) == 28

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

test_input = { "nums": [93,92,92,91,90,90,89,88] }
assert my_solution.continuousSubarrays(**test_input) == 27

test_input = { "nums": [13,13,12,11] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [22,22,22,21,22,21] }
assert my_solution.continuousSubarrays(**test_input) == 21

test_input = { "nums": [24,25,26,26,25,26,25,25,26] }
assert my_solution.continuousSubarrays(**test_input) == 45

test_input = { "nums": [37,36] }
assert my_solution.continuousSubarrays(**test_input) == 3

test_input = { "nums": [52,51] }
assert my_solution.continuousSubarrays(**test_input) == 3

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

test_input = { "nums": [88,88,88,87,87,87,87,88,88] }
assert my_solution.continuousSubarrays(**test_input) == 45

test_input = { "nums": [84,83,83,84,83,82,81] }
assert my_solution.continuousSubarrays(**test_input) == 24

test_input = { "nums": [87,88,88,87,87,88,88,89] }
assert my_solution.continuousSubarrays(**test_input) == 36

test_input = { "nums": [28,28,27] }
assert my_solution.continuousSubarrays(**test_input) == 6

test_input = { "nums": [82,83,83,82] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [97,96,96,95,96,95] }
assert my_solution.continuousSubarrays(**test_input) == 21

test_input = { "nums": [72,73,73,74,73,73] }
assert my_solution.continuousSubarrays(**test_input) == 21

test_input = { "nums": [21,21,20] }
assert my_solution.continuousSubarrays(**test_input) == 6

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

test_input = { "nums": [24,24,24,23,22,22,22,23] }
assert my_solution.continuousSubarrays(**test_input) == 36

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

test_input = { "nums": [11,10,9,10,11] }
assert my_solution.continuousSubarrays(**test_input) == 15

test_input = { "nums": [34,34,35,34,35,36,36] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [73,74,75,75] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [24,23,24,24] }
assert my_solution.continuousSubarrays(**test_input) == 10

test_input = { "nums": [21,22,22,23,22,23,22,23,23,22] }
assert my_solution.continuousSubarrays(**test_input) == 55

test_input = { "nums": [53,53,54,54,54] }
assert my_solution.continuousSubarrays(**test_input) == 15

test_input = { "nums": [94,95,96,96,97,97,98,99] }
assert my_solution.continuousSubarrays(**test_input) == 28

test_input = { "nums": [89,89,89,88,87,87] }
assert my_solution.continuousSubarrays(**test_input) == 21

test_input = { "nums": [89,90] }
assert my_solution.continuousSubarrays(**test_input) == 3

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


sum-of-imbalance-numbers-of-all-subarrays

Sum of Imbalance Numbers of All Subarrays

Prompt:
"""
The imbalance number of a 0-indexed integer array arr of length n is defined as the number of indices in sarr = sorted(arr) such that:

 * 0 <= i < n - 1, and
 * sarr[i+1] - sarr[i] > 1

Here, sorted(arr) is the function that returns the sorted version of arr.

Given a 0-indexed integer array nums, return the sum of imbalance numbers of all its subarrays.

A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [2,3,1,4]
Output: 3
Explanation: There are 3 subarrays with non-zero imbalance numbers:
- Subarray [3, 1] with an imbalance number of 1.
- Subarray [3, 1, 4] with an imbalance number of 1.
- Subarray [1, 4] with an imbalance number of 1.
The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 3.

Example 2:

Input: nums = [1,3,3,3,5]
Output: 8
Explanation: There are 7 subarrays with non-zero imbalance numbers:
- Subarray [1, 3] with an imbalance number of 1.
- Subarray [1, 3, 3] with an imbalance number of 1.
- Subarray [1, 3, 3, 3] with an imbalance number of 1.
- Subarray [1, 3, 3, 3, 5] with an imbalance number of 2.
- Subarray [3, 3, 3, 5] with an imbalance number of 1.
- Subarray [3, 3, 5] with an imbalance number of 1.
- Subarray [3, 5] with an imbalance number of 1.
The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 8.

Constraints:

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

The imbalance number of a 0-indexed integer array arr of length n is defined as the number of indices in sarr = sorted(arr) such that:

 * 0 <= i < n - 1, and
 * sarr[i+1] - sarr[i] > 1

Here, sorted(arr) is the function that returns the sorted version of arr.

Given a 0-indexed integer array nums, return the sum of imbalance numbers of all its subarrays.

A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [2,3,1,4]
Output: 3
Explanation: There are 3 subarrays with non-zero imbalance numbers:
- Subarray [3, 1] with an imbalance number of 1.
- Subarray [3, 1, 4] with an imbalance number of 1.
- Subarray [1, 4] with an imbalance number of 1.
The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 3.

Example 2:

Input: nums = [1,3,3,3,5]
Output: 8
Explanation: There are 7 subarrays with non-zero imbalance numbers:
- Subarray [1, 3] with an imbalance number of 1.
- Subarray [1, 3, 3] with an imbalance number of 1.
- Subarray [1, 3, 3, 3] with an imbalance number of 1.
- Subarray [1, 3, 3, 3, 5] with an imbalance number of 2.
- Subarray [3, 3, 3, 5] with an imbalance number of 1.
- Subarray [3, 3, 5] with an imbalance number of 1.
- Subarray [3, 5] with an imbalance number of 1.
The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 8.

Constraints:

 * 1 <= nums.length <= 1000
 * 1 <= nums[i] <= nums.length

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

```

my_solution = Solution()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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