# Count the Number of Vowel Strings in Range

You are given a **0-indexed** array of string `words` and two integers `left` and `right`.

A string is called a **vowel string** if it starts with a vowel character and ends with a vowel character where vowel characters are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`.

Return *the number of vowel strings* `words[i]` *where* `i` *belongs to the inclusive range* `[left, right]`.

**Example 1:**

```

**Input:** words = ["are","amy","u"], left = 0, right = 2
**Output:** 2
**Explanation:**
- "are" is a vowel string because it starts with 'a' and ends with 'e'.
- "amy" is not a vowel string because it does not end with a vowel.
- "u" is a vowel string because it starts with 'u' and ends with 'u'.
The number of vowel strings in the mentioned range is 2.

```

**Example 2:**

```

**Input:** words = ["hey","aeo","mu","ooo","artro"], left = 1, right = 4
**Output:** 3
**Explanation:**
- "aeo" is a vowel string because it starts with 'a' and ends with 'o'.
- "mu" is not a vowel string because it does not start with a vowel.
- "ooo" is a vowel string because it starts with 'o' and ends with 'o'.
- "artro" is a vowel string because it starts with 'a' and ends with 'o'.
The number of vowel strings in the mentioned range is 3.

```

**Constraints:**

* `1 <= words.length <= 1000`
* `1 <= words[i].length <= 10`
* `words[i]` consists of only lowercase English letters.
* `0 <= left <= right < words.length`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def vowelStrings(self, words: List[str], left: int, right: int) -> int:
```

my_solution = Solution()

assert my_solution.vowelStrings(**[['are', 'amy', 'u'], 0, 2]) == 2
assert my_solution.vowelStrings(**[['hey', 'aeo', 'mu', 'ooo', 'artro'], 1, 4]) == 3
assert my_solution.vowelStrings(**[['si'], 0, 0]) == 0
assert my_solution.vowelStrings(**[['ce', 'ai'], 1, 1]) == 1
assert my_solution.vowelStrings(**[['n', 'a', 'o'], 0, 2]) == 2
assert my_solution.vowelStrings(**[['v', 'ab', 'fu', 'nu'], 1, 3]) == 0
assert my_solution.vowelStrings(**[['vo', 'j', 'i', 's', 'i'], 0, 3]) == 1
assert my_solution.vowelStrings(**[['o'], 0, 0]) == 1
assert my_solution.vowelStrings(**[['e', 'ey'], 0, 1]) == 1
assert my_solution.vowelStrings(**[['m', 'qi', 'ae'], 1, 1]) == 0
assert my_solution.vowelStrings(**[['p', 'o', 'ud', 'eq'], 0, 0]) == 0
assert my_solution.vowelStrings(**[['e', 'a', 'o', 'i', 'u'], 0, 0]) == 1
assert my_solution.vowelStrings(**[['f'], 0, 0]) == 0
assert my_solution.vowelStrings(**[['i', 'cz'], 0, 1]) == 1
assert my_solution.vowelStrings(**[['a', 'ui', 'ap'], 1, 2]) == 1
assert my_solution.vowelStrings(**[['r', 'sa', 'oa', 'v'], 2, 3]) == 1
assert my_solution.vowelStrings(**[['ez', 'i', 'z', 'ka', 'oi'], 0, 2]) == 1
assert my_solution.vowelStrings(**[['p', 'b'], 0, 1]) == 0
assert my_solution.vowelStrings(**[['gs', 'dt', 'v'], 0, 2]) == 0
assert my_solution.vowelStrings(**[['i', 'or', 'au', 'ii'], 1, 3]) == 2


# Rearrange Array to Maximize Prefix Score

You are given a **0-indexed** integer array `nums`. You can rearrange the elements of `nums` to **any order** (including the given order).

Let `prefix` be the array containing the prefix sums of `nums` after rearranging it. In other words, `prefix[i]` is the sum of the elements from `0` to `i` in `nums` after rearranging it. The **score** of `nums` is the number of positive integers in the array `prefix`.

Return *the maximum score you can achieve*.

**Example 1:**

```

**Input:** nums = [2,-1,0,1,-3,3,-3]
**Output:** 6
**Explanation:** We can rearrange the array into nums = [2,3,1,-1,-3,0,-3].
prefix = [2,5,6,5,2,2,-1], so the score is 6.
It can be shown that 6 is the maximum score we can obtain.

```

**Example 2:**

```

**Input:** nums = [-2,-3,0]
**Output:** 0
**Explanation:** Any rearrangement of the array will result in a score of 0.

```

**Constraints:**

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

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def maxScore(self, nums: List[int]) -> int:
```


# Count the Number of Beautiful Subarrays

You are given a **0-indexed** integer array `nums`. In one operation, you can:

* Choose two different indices `i` and `j` such that `0 <= i, j < nums.length`.
* Choose a non-negative integer `k` such that the `kth` bit (**0-indexed**) in the binary representation of `nums[i]` and `nums[j]` is `1`.
* Subtract `2k` from `nums[i]` and `nums[j]`.

A subarray is **beautiful** if it is possible to make all of its elements equal to `0` after applying the above operation any number of times.

Return *the number of **beautiful subarrays** in the array* `nums`.

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

**Example 1:**

```

**Input:** nums = [4,3,1,2,4]
**Output:** 2
**Explanation:** There are 2 beautiful subarrays in nums: [4,3,1,2,4] and [4,3,1,2,4].
- We can make all elements in the subarray [3,1,2] equal to 0 in the following way:
  - Choose [3, 1, 2] and k = 1. Subtract 21 from both numbers. The subarray becomes [1, 1, 0].
  - Choose [1, 1, 0] and k = 0. Subtract 20 from both numbers. The subarray becomes [0, 0, 0].
- We can make all elements in the subarray [4,3,1,2,4] equal to 0 in the following way:
  - Choose [4, 3, 1, 2, 4] and k = 2. Subtract 22 from both numbers. The subarray becomes [0, 3, 1, 2, 0].
  - Choose [0, 3, 1, 2, 0] and k = 0. Subtract 20 from both numbers. The subarray becomes [0, 2, 0, 2, 0].
  - Choose [0, 2, 0, 2, 0] and k = 1. Subtract 21 from both numbers. The subarray becomes [0, 0, 0, 0, 0].

```

**Example 2:**

```

**Input:** nums = [1,10,4]
**Output:** 0
**Explanation:** There are no beautiful subarrays in nums.

```

**Constraints:**

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

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def beautifulSubarrays(self, nums: List[int]) -> int:
```

my_solution = Solution()

assert my_solution.beautifulSubarrays(**[[4, 3, 1, 2, 4]]) == 2
assert my_solution.beautifulSubarrays(**[[1, 10, 4]]) == 0
assert my_solution.beautifulSubarrays(**[[0]]) == 1
assert my_solution.beautifulSubarrays(**[[1]]) == 0
assert my_solution.beautifulSubarrays(**[[0, 0]]) == 3
assert my_solution.beautifulSubarrays(**[[0, 1]]) == 1
assert my_solution.beautifulSubarrays(**[[1, 0]]) == 1
assert my_solution.beautifulSubarrays(**[[1, 1]]) == 1
assert my_solution.beautifulSubarrays(**[[0, 0, 0]]) == 6
assert my_solution.beautifulSubarrays(**[[1, 0, 0]]) == 3
assert my_solution.beautifulSubarrays(**[[0, 1, 0]]) == 2
assert my_solution.beautifulSubarrays(**[[1, 1, 0]]) == 3
assert my_solution.beautifulSubarrays(**[[0, 0, 1]]) == 3
assert my_solution.beautifulSubarrays(**[[1, 0, 1]]) == 2
assert my_solution.beautifulSubarrays(**[[0, 1, 1]]) == 3
assert my_solution.beautifulSubarrays(**[[1, 1, 1]]) == 2
assert my_solution.beautifulSubarrays(**[[0, 0, 0, 0]]) == 10
assert my_solution.beautifulSubarrays(**[[1, 0, 0, 0]]) == 6
assert my_solution.beautifulSubarrays(**[[0, 1, 0, 0]]) == 4
assert my_solution.beautifulSubarrays(**[[1, 1, 0, 0]]) == 6


# Minimum Time to Complete All Tasks

There is a computer that can run an unlimited number of tasks **at the same time**. You are given a 2D integer array `tasks` where `tasks[i] = [starti, endi, durationi]` indicates that the `ith` task should run for a total of `durationi` seconds (not necessarily continuous) within the **inclusive** time range `[starti, endi]`.

You may turn on the computer only when it needs to run a task. You can also turn it off if it is idle.

Return *the minimum time during which the computer should be turned on to complete all tasks*.

**Example 1:**

```

**Input:** tasks = [[2,3,1],[4,5,1],[1,5,2]]
**Output:** 2
**Explanation:**
- The first task can be run in the inclusive time range [2, 2].
- The second task can be run in the inclusive time range [5, 5].
- The third task can be run in the two inclusive time ranges [2, 2] and [5, 5].
The computer will be on for a total of 2 seconds.

```

**Example 2:**

```

**Input:** tasks = [[1,3,2],[2,5,3],[5,6,2]]
**Output:** 4
**Explanation:**
- The first task can be run in the inclusive time range [2, 3].
- The second task can be run in the inclusive time ranges [2, 3] and [5, 5].
- The third task can be run in the two inclusive time range [5, 6].
The computer will be on for a total of 4 seconds.

```

**Constraints:**

* `1 <= tasks.length <= 2000`
* `tasks[i].length == 3`
* `1 <= starti, endi <= 2000`
* `1 <= durationi <= endi - starti + 1`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def findMinimumTime(self, tasks: List[List[int]]) -> int:
```


# Pass the Pillow

There are `n` people standing in a line labeled from `1` to `n`. The first person in the line is holding a pillow initially. Every second, the person holding the pillow passes it to the next person standing in the line. Once the pillow reaches the end of the line, the direction changes, and people continue passing the pillow in the opposite direction.

* For example, once the pillow reaches the `nth` person they pass it to the `n - 1th` person, then to the `n - 2th` person and so on.

Given the two positive integers `n` and `time`, return *the index of the person holding the pillow after* `time` *seconds*.

**Example 1:**

```

**Input:** n = 4, time = 5
**Output:** 2
**Explanation:** People pass the pillow in the following way: 1 -> 2 -> 3 -> 4 -> 3 -> 2.
Afer five seconds, the pillow is given to the 2nd person.

```

**Example 2:**

```

**Input:** n = 3, time = 2
**Output:** 3
**Explanation:** People pass the pillow in the following way: 1 -> 2 -> 3.
Afer two seconds, the pillow is given to the 3rd person.

```

**Constraints:**

* `2 <= n <= 1000`
* `1 <= time <= 1000`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def passThePillow(self, n: int, time: int) -> int:
```

my_solution = Solution()

assert my_solution.passThePillow(**[4, 5]) == 2
assert my_solution.passThePillow(**[3, 2]) == 3
assert my_solution.passThePillow(**[9, 4]) == 5
assert my_solution.passThePillow(**[8, 9]) == 6
assert my_solution.passThePillow(**[20, 9]) == 10
assert my_solution.passThePillow(**[6, 8]) == 3
assert my_solution.passThePillow(**[8, 2]) == 3
assert my_solution.passThePillow(**[82, 26]) == 27
assert my_solution.passThePillow(**[18, 38]) == 5
assert my_solution.passThePillow(**[43, 13]) == 14
assert my_solution.passThePillow(**[76, 23]) == 24
assert my_solution.passThePillow(**[36, 20]) == 21
assert my_solution.passThePillow(**[14, 20]) == 7
assert my_solution.passThePillow(**[73, 27]) == 28
assert my_solution.passThePillow(**[53, 46]) == 47
assert my_solution.passThePillow(**[93, 22]) == 23
assert my_solution.passThePillow(**[66, 48]) == 49
assert my_solution.passThePillow(**[2, 341]) == 2
assert my_solution.passThePillow(**[33, 218]) == 27
assert my_solution.passThePillow(**[69, 81]) == 56


# Number of Ways to Earn Points

There is a test that has `n` types of questions. You are given an integer `target` and a **0-indexed** 2D integer array `types` where `types[i] = [counti, marksi]` indicates that there are `counti` questions of the `ith` type, and each one of them is worth `marksi` points.

Return *the number of ways you can earn **exactly*** `target` *points in the exam*. Since the answer may be too large, return it **modulo** `109 + 7`.

**Note** that questions of the same type are indistinguishable.

* For example, if there are `3` questions of the same type, then solving the `1st` and `2nd` questions is the same as solving the `1st` and `3rd` questions, or the `2nd` and `3rd` questions.

**Example 1:**

```

**Input:** target = 6, types = [[6,1],[3,2],[2,3]]
**Output:** 7
**Explanation:** You can earn 6 points in one of the seven ways:
- Solve 6 questions of the 0th type: 1 + 1 + 1 + 1 + 1 + 1 = 6
- Solve 4 questions of the 0th type and 1 question of the 1st type: 1 + 1 + 1 + 1 + 2 = 6
- Solve 2 questions of the 0th type and 2 questions of the 1st type: 1 + 1 + 2 + 2 = 6
- Solve 3 questions of the 0th type and 1 question of the 2nd type: 1 + 1 + 1 + 3 = 6
- Solve 1 question of the 0th type, 1 question of the 1st type and 1 question of the 2nd type: 1 + 2 + 3 = 6
- Solve 3 questions of the 1st type: 2 + 2 + 2 = 6
- Solve 2 questions of the 2nd type: 3 + 3 = 6

```

**Example 2:**

```

**Input:** target = 5, types = [[50,1],[50,2],[50,5]]
**Output:** 4
**Explanation:** You can earn 5 points in one of the four ways:
- Solve 5 questions of the 0th type: 1 + 1 + 1 + 1 + 1 = 5
- Solve 3 questions of the 0th type and 1 question of the 1st type: 1 + 1 + 1 + 2 = 5
- Solve 1 questions of the 0th type and 2 questions of the 1st type: 1 + 2 + 2 = 5
- Solve 1 question of the 2nd type: 5

```

**Example 3:**

```

**Input:** target = 18, types = [[6,1],[3,2],[2,3]]
**Output:** 1
**Explanation:** You can only earn 18 points by answering all questions.

```

**Constraints:**

* `1 <= target <= 1000`
* `n == types.length`
* `1 <= n <= 50`
* `types[i].length == 2`
* `1 <= counti, marksi <= 50`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def waysToReachTarget(self, target: int, types: List[List[int]]) -> int:
```


# Split With Minimum Sum

Given a positive integer `num`, split it into two non-negative integers `num1` and `num2` such that:

* The concatenation of `num1` and `num2` is a permutation of `num`.
	+ In other words, the sum of the number of occurrences of each digit in `num1` and `num2` is equal to the number of occurrences of that digit in `num`.
* `num1` and `num2` can contain leading zeros.

Return *the **minimum** possible sum of* `num1` *and* `num2`.

**Notes:**

* It is guaranteed that `num` does not contain any leading zeros.
* The order of occurrence of the digits in `num1` and `num2` may differ from the order of occurrence of `num`.

**Example 1:**

```

**Input:** num = 4325
**Output:** 59
**Explanation:** We can split 4325 so that num1 is 24 and num2 is 35, giving a sum of 59. We can prove that 59 is indeed the minimal possible sum.

```

**Example 2:**

```

**Input:** num = 687
**Output:** 75
**Explanation:** We can split 687 so that num1 is 68 and num2 is 7, which would give an optimal sum of 75.

```

**Constraints:**

* `10 <= num <= 109`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def splitNum(self, num: int) -> int:
```

my_solution = Solution()

assert my_solution.splitNum(**[4325]) == 59
assert my_solution.splitNum(**[687]) == 75
assert my_solution.splitNum(**[10]) == 1
assert my_solution.splitNum(**[11]) == 2
assert my_solution.splitNum(**[12]) == 3
assert my_solution.splitNum(**[13]) == 4
assert my_solution.splitNum(**[14]) == 5
assert my_solution.splitNum(**[15]) == 6
assert my_solution.splitNum(**[16]) == 7
assert my_solution.splitNum(**[17]) == 8
assert my_solution.splitNum(**[18]) == 9
assert my_solution.splitNum(**[19]) == 10
assert my_solution.splitNum(**[20]) == 2
assert my_solution.splitNum(**[21]) == 3
assert my_solution.splitNum(**[22]) == 4
assert my_solution.splitNum(**[23]) == 5
assert my_solution.splitNum(**[24]) == 6
assert my_solution.splitNum(**[25]) == 7
assert my_solution.splitNum(**[26]) == 8
assert my_solution.splitNum(**[27]) == 9


# Count Ways to Group Overlapping Ranges

You are given a 2D integer array `ranges` where `ranges[i] = [starti, endi]` denotes that all integers between `starti` and `endi` (both **inclusive**) are contained in the `ith` range.

You are to split `ranges` into **two** (possibly empty) groups such that:

* Each range belongs to exactly one group.
* Any two **overlapping** ranges must belong to the **same** group.

Two ranges are said to be **overlapping** if there exists at least **one** integer that is present in both ranges.

* For example, `[1, 3]` and `[2, 5]` are overlapping because `2` and `3` occur in both ranges.

Return *the **total number** of ways to split* `ranges` *into two groups*. Since the answer may be very large, return it **modulo** `109 + 7`.

**Example 1:**

```

**Input:** ranges = [[6,10],[5,15]]
**Output:** 2
**Explanation:**
The two ranges are overlapping, so they must be in the same group.
Thus, there are two possible ways:
- Put both the ranges together in group 1.
- Put both the ranges together in group 2.

```

**Example 2:**

```

**Input:** ranges = [[1,3],[10,20],[2,5],[4,8]]
**Output:** 4
**Explanation:**
Ranges [1,3], and [2,5] are overlapping. So, they must be in the same group.
Again, ranges [2,5] and [4,8] are also overlapping. So, they must also be in the same group.
Thus, there are four possible ways to group them:
- All the ranges in group 1.
- All the ranges in group 2.
- Ranges [1,3], [2,5], and [4,8] in group 1 and [10,20] in group 2.
- Ranges [1,3], [2,5], and [4,8] in group 2 and [10,20] in group 1.

```

**Constraints:**

* `1 <= ranges.length <= 105`
* `ranges[i].length == 2`
* `0 <= starti <= endi <= 109`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def countWays(self, ranges: List[List[int]]) -> int:
```


# Left and Right Sum Differences

Given a **0-indexed** integer array `nums`, find a **0-indexed** integer array `answer` where:

* `answer.length == nums.length`.
* `answer[i] = |leftSum[i] - rightSum[i]|`.

Where:

* `leftSum[i]` is the sum of elements to the left of the index `i` in the array `nums`. If there is no such element, `leftSum[i] = 0`.
* `rightSum[i]` is the sum of elements to the right of the index `i` in the array `nums`. If there is no such element, `rightSum[i] = 0`.

Return *the array* `answer`.

**Example 1:**

```

**Input:** nums = [10,4,8,3]
**Output:** [15,1,11,22]
**Explanation:** The array leftSum is [0,10,14,22] and the array rightSum is [15,11,3,0].
The array answer is [|0 - 15|,|10 - 11|,|14 - 3|,|22 - 0|] = [15,1,11,22].

```

**Example 2:**

```

**Input:** nums = [1]
**Output:** [0]
**Explanation:** The array leftSum is [0] and the array rightSum is [0].
The array answer is [|0 - 0|] = [0].

```

**Constraints:**

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

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def leftRightDifference(self, nums: List[int]) -> List[int]:
```


# Find the Divisibility Array of a String

You are given a **0-indexed** string `word` of length `n` consisting of digits, and a positive integer `m`.

The **divisibility array** `div` of `word` is an integer array of length `n` such that:

* `div[i] = 1` if the **numeric value** of `word[0,...,i]` is divisible by `m`, or
* `div[i] = 0` otherwise.

Return *the divisibility array of*`word`.

**Example 1:**

```

**Input:** word = "998244353", m = 3
**Output:** [1,1,0,0,0,1,1,0,0]
**Explanation:** There are only 4 prefixes that are divisible by 3: "9", "99", "998244", and "9982443".

```

**Example 2:**

```

**Input:** word = "1010", m = 10
**Output:** [0,1,0,1]
**Explanation:** There are only 2 prefixes that are divisible by 10: "10", and "1010".

```

**Constraints:**

* `1 <= n <= 105`
* `word.length == n`
* `word` consists of digits from `0` to `9`
* `1 <= m <= 109`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def divisibilityArray(self, word: str, m: int) -> List[int]:
```


# Find the Maximum Number of Marked Indices

You are given a **0-indexed** integer array `nums`.

Initially, all of the indices are unmarked. You are allowed to make this operation any number of times:

* Pick two **different unmarked** indices `i` and `j` such that `2 * nums[i] <= nums[j]`, then mark `i` and `j`.

Return *the maximum possible number of marked indices in `nums` using the above operation any number of times*.

**Example 1:**

```

**Input:** nums = [3,5,2,4]
**Output:** 2
**Explanation:** In the first operation: pick i = 2 and j = 1, the operation is allowed because 2 * nums[2] <= nums[1]. Then mark index 2 and 1.
It can be shown that there's no other valid operation so the answer is 2.

```

**Example 2:**

```

**Input:** nums = [9,2,5,4]
**Output:** 4
**Explanation:** In the first operation: pick i = 3 and j = 0, the operation is allowed because 2 * nums[3] <= nums[0]. Then mark index 3 and 0.
In the second operation: pick i = 1 and j = 2, the operation is allowed because 2 * nums[1] <= nums[2]. Then mark index 1 and 2.
Since there is no other operation, the answer is 4.

```

**Example 3:**

```

**Input:** nums = [7,6,8]
**Output:** 0
**Explanation:** There is no valid operation to do, so the answer is 0.

```

**Constraints:**

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

.spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0;
}
.spoiler {overflow:hidden;}
.spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;}
.spoilerbutton[value="Show Message"] + .spoiler > div {margin-top:-500%;}
.spoilerbutton[value="Hide Message"] + .spoiler {padding:5px;}

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def maxNumOfMarkedIndices(self, nums: List[int]) -> int:
```


# Merge Two 2D Arrays by Summing Values

You are given two **2D** integer arrays `nums1` and `nums2.`

* `nums1[i] = [idi, vali]` indicate that the number with the id `idi` has a value equal to `vali`.
* `nums2[i] = [idi, vali]` indicate that the number with the id `idi` has a value equal to `vali`.

Each array contains **unique** ids and is sorted in **ascending** order by id.

Merge the two arrays into one array that is sorted in ascending order by id, respecting the following conditions:

* Only ids that appear in at least one of the two arrays should be included in the resulting array.
* Each id should be included **only once** and its value should be the sum of the values of this id in the two arrays. If the id does not exist in one of the two arrays then its value in that array is considered to be `0`.

Return *the resulting array*. The returned array must be sorted in ascending order by id.

**Example 1:**

```

**Input:** nums1 = [[1,2],[2,3],[4,5]], nums2 = [[1,4],[3,2],[4,1]]
**Output:** [[1,6],[2,3],[3,2],[4,6]]
**Explanation:** The resulting array contains the following:
- id = 1, the value of this id is 2 + 4 = 6.
- id = 2, the value of this id is 3.
- id = 3, the value of this id is 2.
- id = 4, the value of this id is 5 + 1 = 6.

```

**Example 2:**

```

**Input:** nums1 = [[2,4],[3,6],[5,5]], nums2 = [[1,3],[4,3]]
**Output:** [[1,3],[2,4],[3,6],[4,3],[5,5]]
**Explanation:** There are no common ids, so we just include each id with its value in the resulting list.

```

**Constraints:**

* `1 <= nums1.length, nums2.length <= 200`
* `nums1[i].length == nums2[j].length == 2`
* `1 <= idi, vali <= 1000`
* Both arrays contain unique ids.
* Both arrays are in strictly ascending order by id.

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def mergeArrays(self, nums1: List[List[int]], nums2: List[List[int]]) -> List[List[int]]:
```


# Minimum Operations to Reduce an Integer to 0

You are given a positive integer `n`, you can do the following operation **any** number of times:

* Add or subtract a **power** of `2` from `n`.

Return *the **minimum** number of operations to make* `n` *equal to* `0`.

A number `x` is power of `2` if `x == 2i` where `i >= 0`*.*

**Example 1:**

```

**Input:** n = 39
**Output:** 3
**Explanation:** We can do the following operations:
- Add 20 = 1 to n, so now n = 40.
- Subtract 23 = 8 from n, so now n = 32.
- Subtract 25 = 32 from n, so now n = 0.
It can be shown that 3 is the minimum number of operations we need to make n equal to 0.

```

**Example 2:**

```

**Input:** n = 54
**Output:** 3
**Explanation:** We can do the following operations:
- Add 21 = 2 to n, so now n = 56.
- Add 23 = 8 to n, so now n = 64.
- Subtract 26 = 64 from n, so now n = 0.
So the minimum number of operations is 3.

```

**Constraints:**

* `1 <= n <= 105`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def minOperations(self, n: int) -> int:
```

my_solution = Solution()

assert my_solution.minOperations(**[39]) == 3
assert my_solution.minOperations(**[54]) == 3
assert my_solution.minOperations(**[38]) == 3
assert my_solution.minOperations(**[70]) == 3
assert my_solution.minOperations(**[26]) == 3
assert my_solution.minOperations(**[27]) == 3
assert my_solution.minOperations(**[1]) == 1
assert my_solution.minOperations(**[71]) == 3
assert my_solution.minOperations(**[15]) == 2
assert my_solution.minOperations(**[25]) == 3
assert my_solution.minOperations(**[33]) == 2
assert my_solution.minOperations(**[84]) == 3
assert my_solution.minOperations(**[30]) == 2
assert my_solution.minOperations(**[82]) == 3
assert my_solution.minOperations(**[16]) == 1
assert my_solution.minOperations(**[88]) == 3
assert my_solution.minOperations(**[533]) == 4
assert my_solution.minOperations(**[580]) == 3
assert my_solution.minOperations(**[668]) == 4
assert my_solution.minOperations(**[404]) == 4


# Count the Number of Square-Free Subsets

You are given a positive integer **0-indexed** array `nums`.

A subset of the array `nums` is **square-free** if the product of its elements is a **square-free integer**.

A **square-free integer** is an integer that is divisible by no square number other than `1`.

Return *the number of square-free non-empty subsets of the array* **nums**. Since the answer may be too large, return it **modulo** `109 + 7`.

A **non-empty** **subset** of `nums` is an array that can be obtained by deleting some (possibly none but not all) elements from `nums`. Two subsets are different if and only if the chosen indices to delete are different.

**Example 1:**

```

**Input:** nums = [3,4,4,5]
**Output:** 3
**Explanation:** There are 3 square-free subsets in this example:
- The subset consisting of the 0th element [3]. The product of its elements is 3, which is a square-free integer.
- The subset consisting of the 3rd element [5]. The product of its elements is 5, which is a square-free integer.
- The subset consisting of 0th and 3rd elements [3,5]. The product of its elements is 15, which is a square-free integer.
It can be proven that there are no more than 3 square-free subsets in the given array.
```

**Example 2:**

```

**Input:** nums = [1]
**Output:** 1
**Explanation:** There is 1 square-free subset in this example:
- The subset consisting of the 0th element [1]. The product of its elements is 1, which is a square-free integer.
It can be proven that there is no more than 1 square-free subset in the given array.

```

**Constraints:**

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

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def squareFreeSubsets(self, nums: List[int]) -> int:
```


# Find the String with LCP

We define the `lcp` matrix of any **0-indexed** string `word` of `n` lowercase English letters as an `n x n` grid such that:

* `lcp[i][j]` is equal to the length of the **longest common prefix** between the substrings `word[i,n-1]` and `word[j,n-1]`.

Given an `n x n` matrix `lcp`, return the alphabetically smallest string `word` that corresponds to `lcp`. If there is no such string, return an empty string.

A string `a` is lexicographically smaller than a string `b` (of the same length) if in the first position where `a` and `b` differ, string `a` has a letter that appears earlier in the alphabet than the corresponding letter in `b`. For example, `"aabd"` is lexicographically smaller than `"aaca"` because the first position they differ is at the third letter, and `'b'` comes before `'c'`.

**Example 1:**

```

**Input:** lcp = [[4,0,2,0],[0,3,0,1],[2,0,2,0],[0,1,0,1]]
**Output:** "abab"
**Explanation:** lcp corresponds to any 4 letter string with two alternating letters. The lexicographically smallest of them is "abab".

```

**Example 2:**

```

**Input:** lcp = [[4,3,2,1],[3,3,2,1],[2,2,2,1],[1,1,1,1]]
**Output:** "aaaa"
**Explanation:** lcp corresponds to any 4 letter string with a single distinct letter. The lexicographically smallest of them is "aaaa".

```

**Example 3:**

```

**Input:** lcp = [[4,3,2,1],[3,3,2,1],[2,2,2,1],[1,1,1,3]]
**Output:** ""
**Explanation:** lcp[3][3] cannot be equal to 3 since word[3,...,3] consists of only a single letter; Thus, no answer exists.

```

**Constraints:**

* `1 <= n ==``lcp.length ==` `lcp[i].length` `<= 1000`
* `0 <= lcp[i][j] <= n`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def findTheString(self, lcp: List[List[int]]) -> str:
```

Output: abab

Output: aaaa

Output: a

Output: ab

Output: aa

Output: abcbbaab

Output: aabababba

Output: aaabbcacbbaabb


# Maximum Difference by Remapping a Digit

You are given an integer `num`. You know that Bob will sneakily **remap** one of the `10` possible digits (`0` to `9`) to another digit.

Return *the difference between the maximum and minimum values Bob can make by remapping **exactly** **one** digit in* `num`.

**Notes:**

* When Bob remaps a digit d1 to another digit d2, Bob replaces all occurrences of `d1` in `num` with `d2`.
* Bob can remap a digit to itself, in which case `num` does not change.
* Bob can remap different digits for obtaining minimum and maximum values respectively.
* The resulting number after remapping can contain leading zeroes.

**Example 1:**

```

**Input:** num = 11891
**Output:** 99009
**Explanation:**
To achieve the maximum value, Bob can remap the digit 1 to the digit 9 to yield 99899.
To achieve the minimum value, Bob can remap the digit 1 to the digit 0, yielding 890.
The difference between these two numbers is 99009.

```

**Example 2:**

```

**Input:** num = 90
**Output:** 99
**Explanation:**
The maximum value that can be returned by the function is 99 (if 0 is replaced by 9) and the minimum value that can be returned by the function is 0 (if 9 is replaced by 0).
Thus, we return 99.
```

**Constraints:**

* `1 <= num <= 108`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def minMaxDifference(self, num: int) -> int:
```

my_solution = Solution()

assert my_solution.minMaxDifference(**[11891]) == 99009
assert my_solution.minMaxDifference(**[90]) == 99
assert my_solution.minMaxDifference(**[22222]) == 99999
assert my_solution.minMaxDifference(**[99999]) == 99999
assert my_solution.minMaxDifference(**[456]) == 900
assert my_solution.minMaxDifference(**[999]) == 999
assert my_solution.minMaxDifference(**[909]) == 999
assert my_solution.minMaxDifference(**[900]) == 999
assert my_solution.minMaxDifference(**[199]) == 900
assert my_solution.minMaxDifference(**[911]) == 988
assert my_solution.minMaxDifference(**[867]) == 900
assert my_solution.minMaxDifference(**[100000000]) == 900000000
assert my_solution.minMaxDifference(**[95334529]) == 94000409
assert my_solution.minMaxDifference(**[70682999]) == 90000000
assert my_solution.minMaxDifference(**[90693669]) == 99090009
assert my_solution.minMaxDifference(**[97746064]) == 92200000
assert my_solution.minMaxDifference(**[72792650]) == 90900000
assert my_solution.minMaxDifference(**[51734886]) == 90000000
assert my_solution.minMaxDifference(**[39004871]) == 90000000
assert my_solution.minMaxDifference(**[77448854]) == 99000000


# Minimum Score by Changing Two Elements

You are given a **0-indexed** integer array `nums`.

* The **low** score of `nums` is the minimum value of `|nums[i] - nums[j]|` over all `0 <= i < j < nums.length`.
* The **high** score of `nums` is the maximum value of `|nums[i] - nums[j]|` over all `0 <= i < j < nums.length`.
* The **score** of `nums` is the sum of the **high** and **low** scores of nums.

To minimize the score of `nums`, we can change the value of **at most two** elements of `nums`.

Return *the **minimum** possible **score** after changing the value of **at most two** elements o*f `nums`.

Note that `|x|` denotes the absolute value of `x`.

**Example 1:**

```

**Input:** nums = [1,4,3]
**Output:** 0
**Explanation:** Change value of nums[1] and nums[2] to 1 so that nums becomes [1,1,1]. Now, the value of |nums[i] - nums[j]| is always equal to 0, so we return 0 + 0 = 0.

```

**Example 2:**

```

**Input:** nums = [1,4,7,8,5]
**Output:** 3
**Explanation:** Change nums[0] and nums[1] to be 6. Now nums becomes [6,6,7,8,5].
Our low score is achieved when i = 0 and j = 1, in which case |nums[i] - nums[j]| = |6 - 6| = 0.
Our high score is achieved when i = 3 and j = 4, in which case |nums[i] - nums[j]| = |8 - 5| = 3.
The sum of our high and low score is 3, which we can prove to be minimal.

```

**Constraints:**

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

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def minimizeSum(self, nums: List[int]) -> int:
```


# Minimum Impossible OR

You are given a **0-indexed** integer array `nums`.

We say that an integer x is **expressible** from `nums` if there exist some integers `0 <= index1 < index2 < ... < indexk < nums.length` for which `nums[index1] | nums[index2] | ... | nums[indexk] = x`. In other words, an integer is expressible if it can be written as the bitwise OR of some subsequence of `nums`.

Return *the minimum **positive non-zero integer** that is not* *expressible from* `nums`.

**Example 1:**

```

**Input:** nums = [2,1]
**Output:** 4
**Explanation:** 1 and 2 are already present in the array. We know that 3 is expressible, since nums[0] | nums[1] = 2 | 1 = 3. Since 4 is not expressible, we return 4.

```

**Example 2:**

```

**Input:** nums = [5,3,2]
**Output:** 1
**Explanation:** We can show that 1 is the smallest number that is not expressible.

```

**Constraints:**

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

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def minImpossibleOR(self, nums: List[int]) -> int:
```

my_solution = Solution()

assert my_solution.minImpossibleOR(**[[2, 1]]) == 4
assert my_solution.minImpossibleOR(**[[5, 3, 2]]) == 1
assert my_solution.minImpossibleOR(**[[1, 25, 2, 72]]) == 4
assert my_solution.minImpossibleOR(**[[4, 32, 16, 8, 8, 75, 1, 2]]) == 64
assert my_solution.minImpossibleOR(**[[25, 2, 1, 92, 8, 4, 16]]) == 32
assert my_solution.minImpossibleOR(**[[4, 1, 2, 8, 8, 16]]) == 32
assert my_solution.minImpossibleOR(**[[2, 64, 1, 32, 4, 8, 16]]) == 128
assert my_solution.minImpossibleOR(**[[1, 4, 2]]) == 8
assert my_solution.minImpossibleOR(**[[4, 2, 1]]) == 8
assert my_solution.minImpossibleOR(**[[21, 1]]) == 2
assert my_solution.minImpossibleOR(**[[2, 4, 16, 1, 128, 64, 32, 8]]) == 256
assert my_solution.minImpossibleOR(**[[1, 2, 4]]) == 8
assert my_solution.minImpossibleOR(**[[4, 2, 8, 1, 87, 16, 6]]) == 32
assert my_solution.minImpossibleOR(**[[96, 1]]) == 2
assert my_solution.minImpossibleOR(**[[2, 1, 88]]) == 4
assert my_solution.minImpossibleOR(**[[76, 2, 96, 82, 4, 8, 24, 1]]) == 16
assert my_solution.minImpossibleOR(**[[1]]) == 2
assert my_solution.minImpossibleOR(**[[6, 8, 46, 57, 59, 97, 4, 2, 1]]) == 16
assert my_solution.minImpossibleOR(**[[2, 46, 1, 1, 24, 55, 71, 63]]) == 4
assert my_solution.minImpossibleOR(**[[2, 8, 32, 1, 4, 16, 43, 64]]) == 128


# Handling Sum Queries After Update

You are given two **0-indexed** arrays `nums1` and `nums2` and a 2D array `queries` of queries. There are three types of queries:

1. For a query of type 1, `queries[i] = [1, l, r]`. Flip the values from `0` to `1` and from `1` to `0` in `nums1` from index `l` to index `r`. Both `l` and `r` are **0-indexed**.
2. For a query of type 2, `queries[i] = [2, p, 0]`. For every index `0 <= i < n`, set `nums2[i] = nums2[i] + nums1[i] * p`.
3. For a query of type 3, `queries[i] = [3, 0, 0]`. Find the sum of the elements in `nums2`.

Return *an array containing all the answers to the third type queries.*

**Example 1:**

```

**Input:** nums1 = [1,0,1], nums2 = [0,0,0], queries = [[1,1,1],[2,1,0],[3,0,0]]
**Output:** [3]
**Explanation:** After the first query nums1 becomes [1,1,1]. After the second query, nums2 becomes [1,1,1], so the answer to the third query is 3. Thus, [3] is returned.

```

**Example 2:**

```

**Input:** nums1 = [1], nums2 = [5], queries = [[2,0,0],[3,0,0]]
**Output:** [5]
**Explanation:** After the first query, nums2 remains [5], so the answer to the second query is 5. Thus, [5] is returned.

```

**Constraints:**

* `1 <= nums1.length,nums2.length <= 105`
* `nums1.length = nums2.length`
* `1 <= queries.length <= 105`
* `queries[i].length = 3`
* `0 <= l <= r <= nums1.length - 1`
* `0 <= p <= 106`
* `0 <= nums1[i] <= 1`
* `0 <= nums2[i] <= 109`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def handleQuery(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]:
```


# Find the Array Concatenation Value

You are given a **0-indexed** integer array `nums`.

The **concatenation** of two numbers is the number formed by concatenating their numerals.

* For example, the concatenation of `15`, `49` is `1549`.

The **concatenation value** of `nums` is initially equal to `0`. Perform this operation until `nums` becomes empty:

* If there exists more than one number in `nums`, pick the first element and last element in `nums` respectively and add the value of their concatenation to the **concatenation value** of `nums`, then delete the first and last element from `nums`.
* If one element exists, add its value to the **concatenation value** of `nums`, then delete it.

Return *the concatenation value of the `nums`*.

**Example 1:**

```

**Input:** nums = [7,52,2,4]
**Output:** 596
**Explanation:** Before performing any operation, nums is [7,52,2,4] and concatenation value is 0.
 - In the first operation:
We pick the first element, 7, and the last element, 4.
Their concatenation is 74, and we add it to the concatenation value, so it becomes equal to 74.
Then we delete them from nums, so nums becomes equal to [52,2].
 - In the second operation:
We pick the first element, 52, and the last element, 2.
Their concatenation is 522, and we add it to the concatenation value, so it becomes equal to 596.
Then we delete them from the nums, so nums becomes empty.
Since the concatenation value is 596 so the answer is 596.

```

**Example 2:**

```

**Input:** nums = [5,14,13,8,12]
**Output:** 673
**Explanation:** Before performing any operation, nums is [5,14,13,8,12] and concatenation value is 0.
 - In the first operation:
We pick the first element, 5, and the last element, 12.
Their concatenation is 512, and we add it to the concatenation value, so it becomes equal to 512.
Then we delete them from the nums, so nums becomes equal to [14,13,8].
 - In the second operation:
We pick the first element, 14, and the last element, 8.
Their concatenation is 148, and we add it to the concatenation value, so it becomes equal to 660.
Then we delete them from the nums, so nums becomes equal to [13].
 - In the third operation:
nums has only one element, so we pick 13 and add it to the concatenation value, so it becomes equal to 673.
Then we delete it from nums, so nums become empty.
Since the concatenation value is 673 so the answer is 673.

```

**Constraints:**

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

.spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0;
}
.spoiler {overflow:hidden;}
.spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;}
.spoilerbutton[value="Show Message"] + .spoiler > div {margin-top:-500%;}
.spoilerbutton[value="Hide Message"] + .spoiler {padding:5px;}

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def findTheArrayConcVal(self, nums: List[int]) -> int:
```


# Count the Number of Fair Pairs

Given a **0-indexed** integer array `nums` of size `n` and two integers `lower` and `upper`, return *the number of fair pairs*.

A pair `(i, j)` is **fair** if:

* `0 <= i < j < n`, and
* `lower <= nums[i] + nums[j] <= upper`

**Example 1:**

```

**Input:** nums = [0,1,7,4,4,5], lower = 3, upper = 6
**Output:** 6
**Explanation:** There are 6 fair pairs: (0,3), (0,4), (0,5), (1,3), (1,4), and (1,5).

```

**Example 2:**

```

**Input:** nums = [1,7,9,2,5], lower = 11, upper = 11
**Output:** 1
**Explanation:** There is a single fair pair: (2,3).

```

**Constraints:**

* `1 <= nums.length <= 105`
* `nums.length == n`
* `-109 <= nums[i] <= 109`
* `-109 <= lower <= upper <= 109`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def countFairPairs(self, nums: List[int], lower: int, upper: int) -> int:
```


# Substring XOR Queries

You are given a **binary string** `s`, and a **2D** integer array `queries` where `queries[i] = [firsti, secondi]`.

For the `ith` query, find the **shortest substring** of `s` whose **decimal value**, `val`, yields `secondi` when **bitwise XORed** with `firsti`. In other words, `val ^ firsti == secondi`.

The answer to the `ith` query is the endpoints (**0-indexed**) of the substring `[lefti, righti]` or `[-1, -1]` if no such substring exists. If there are multiple answers, choose the one with the **minimum** `lefti`.

*Return an array* `ans` *where* `ans[i] = [lefti, righti]` *is the answer to the* `ith` *query.*

A **substring** is a contiguous non-empty sequence of characters within a string.

**Example 1:**

```

**Input:** s = "101101", queries = [[0,5],[1,2]]
**Output:** [[0,2],[2,3]]
**Explanation:** For the first query the substring in range [0,2] is **"101"** which has a decimal value of **`5`**, and **`5 ^ 0 = 5`**, hence the answer to the first query is [0,2]. In the second query, the substring in range [2,3] is **"11",** and has a decimal value of **3**, and **3 `^ 1 = 2`**. So, [2,3] is returned for the second query.

```

**Example 2:**

```

**Input:** s = "0101", queries = [[12,8]]
**Output:** [[-1,-1]]
**Explanation:** In this example there is no substring that answers the query, hence [-1,-1] is returned.

```

**Example 3:**

```

**Input:** s = "1", queries = [[4,5]]
**Output:** [[0,0]]
**Explanation:** For this example, the substring in range [0,0] has a decimal value of **`1`**, and **`1 ^ 4 = 5`**. So, the answer is [0,0].

```

**Constraints:**

* `1 <= s.length <= 104`
* `s[i]` is either `'0'` or `'1'`.
* `1 <= queries.length <= 105`
* `0 <= firsti, secondi <= 109`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def substringXorQueries(self, s: str, queries: List[List[int]]) -> List[List[int]]:
```


# Subsequence With the Minimum Score

You are given two strings `s` and `t`.

You are allowed to remove any number of characters from the string `t`.

The score of the string is `0` if no characters are removed from the string `t`, otherwise:

* Let `left` be the minimum index among all removed characters.
* Let `right` be the maximum index among all removed characters.

Then the score of the string is `right - left + 1`.

Return *the minimum possible score to make* `t`*a subsequence of* `s`*.*

A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., `"ace"` is a subsequence of `"abcde"` while `"aec"` is not).

**Example 1:**

```

**Input:** s = "abacaba", t = "bzaa"
**Output:** 1
**Explanation:** In this example, we remove the character "z" at index 1 (0-indexed).
The string t becomes "baa" which is a subsequence of the string "abacaba" and the score is 1 - 1 + 1 = 1.
It can be proven that 1 is the minimum score that we can achieve.

```

**Example 2:**

```

**Input:** s = "cde", t = "xyz"
**Output:** 3
**Explanation:** In this example, we remove characters "x", "y" and "z" at indices 0, 1, and 2 (0-indexed).
The string t becomes "" which is a subsequence of the string "cde" and the score is 2 - 0 + 1 = 3.
It can be proven that 3 is the minimum score that we can achieve.

```

**Constraints:**

* `1 <= s.length, t.length <= 105`
* `s` and `t` consist of only lowercase English letters.

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def minimumScore(self, s: str, t: str) -> int:
```

my_solution = Solution()

assert my_solution.minimumScore(**['abacaba', 'bzaa']) == 1
assert my_solution.minimumScore(**['cde', 'xyz']) == 3
assert my_solution.minimumScore(**['abecdebe', 'eaebceae']) == 6
assert my_solution.minimumScore(**['acdedcdbabecdbebda', 'bbecddb']) == 1
assert my_solution.minimumScore(**['dabbbeddeabbaccecaee', 'bcbbaabdbebecbebded']) == 16
assert my_solution.minimumScore(**['adebddaccdcabaade', 'adbae']) == 0
assert my_solution.minimumScore(**['dcadebdecbeaedd', 'dcdadeb']) == 1
assert my_solution.minimumScore(**['bcceaaccd', 'cbe']) == 1
assert my_solution.minimumScore(**['cabecaeadeaeadd', 'edcce']) == 2
assert my_solution.minimumScore(**['cbedceeeccd', 'ed']) == 0
assert my_solution.minimumScore(**['eeecaeecdeeadcdbcaa', 'edecabe']) == 2
assert my_solution.minimumScore(**['eceecbabe', 'bdeaec']) == 4
assert my_solution.minimumScore(**['caaa', 'aaa']) == 0
assert my_solution.minimumScore(**['cbaa', 'a']) == 0
assert my_solution.minimumScore(**['bcabcbcccbacccc', 'cbcbb']) == 0
assert my_solution.minimumScore(**['eddbeedbbaaaaadaacccddadccbbcdc', 'aecbddcedaaced']) == 12
assert my_solution.minimumScore(**['ccecdeccaebcdaeaccdceadbaabeddacaeacbaabaec', 'bdadc']) == 0
assert my_solution.minimumScore(**['eaedcdbdeededbcdcbedddbccbaebbdbadbdadccaddacbbcbabadbacbdcbeaebecbacacbadaadedcadcdcdaceaaad', 'cadedebbcabecbcbd']) == 1
assert my_solution.minimumScore(**['aacecebcbbcbacddbdcbaddeadd', 'cab']) == 0
assert my_solution.minimumScore(**['adcdaedbeeecbbaecebceaebcbcddecddcedecddbbdaabcbdbcbbabbddaeaedeabdecaedbcdbdccb', 'abadccaced']) == 0


# Take Gifts From the Richest Pile

You are given an integer array `gifts` denoting the number of gifts in various piles. Every second, you do the following:

* Choose the pile with the maximum number of gifts.
* If there is more than one pile with the maximum number of gifts, choose any.
* Leave behind the floor of the square root of the number of gifts in the pile. Take the rest of the gifts.

Return *the number of gifts remaining after* `k` *seconds.*

**Example 1:**

```

**Input:** gifts = [25,64,9,4,100], k = 4
**Output:** 29
**Explanation:**
The gifts are taken in the following way:
- In the first second, the last pile is chosen and 10 gifts are left behind.
- Then the second pile is chosen and 8 gifts are left behind.
- After that the first pile is chosen and 5 gifts are left behind.
- Finally, the last pile is chosen again and 3 gifts are left behind.
The final remaining gifts are [5,8,9,4,3], so the total number of gifts remaining is 29.

```

**Example 2:**

```

**Input:** gifts = [1,1,1,1], k = 4
**Output:** 4
**Explanation:**
In this case, regardless which pile you choose, you have to leave behind 1 gift in each pile.
That is, you can't take any pile with you.
So, the total gifts remaining are 4.

```

**Constraints:**

* `1 <= gifts.length <= 103`
* `1 <= gifts[i] <= 109`
* `1 <= k <= 103`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def pickGifts(self, gifts: List[int], k: int) -> int:
```


# Count Vowel Strings in Ranges

You are given a **0-indexed** array of strings `words` and a 2D array of integers `queries`.

Each query `queries[i] = [li, ri]` asks us to find the number of strings present in the range `li` to `ri` (both **inclusive**) of `words` that start and end with a vowel.

Return *an array* `ans` *of size* `queries.length`*, where* `ans[i]` *is the answer to the* `i`th *query*.

**Note** that the vowel letters are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`.

**Example 1:**

```

**Input:** words = ["aba","bcb","ece","aa","e"], queries = [[0,2],[1,4],[1,1]]
**Output:** [2,3,0]
**Explanation:** The strings starting and ending with a vowel are "aba", "ece", "aa" and "e".
The answer to the query [0,2] is 2 (strings "aba" and "ece").
to query [1,4] is 3 (strings "ece", "aa", "e").
to query [1,1] is 0.
We return [2,3,0].

```

**Example 2:**

```

**Input:** words = ["a","e","i"], queries = [[0,2],[0,1],[2,2]]
**Output:** [3,2,1]
**Explanation:** Every string satisfies the conditions, so we return [3,2,1].
```

**Constraints:**

* `1 <= words.length <= 105`
* `1 <= words[i].length <= 40`
* `words[i]` consists only of lowercase English letters.
* `sum(words[i].length) <= 3 * 105`
* `1 <= queries.length <= 105`
* `0 <= li <= ri < words.length`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def vowelStrings(self, words: List[str], queries: List[List[int]]) -> List[int]:
```

my_solution = Solution()

assert my_solution.vowelStrings(**[['aba', 'bcb', 'ece', 'aa', 'e'], [[0, 2], [1, 4], [1, 1]]]) == [2, 3, 0]
assert my_solution.vowelStrings(**[['a', 'e', 'i'], [[0, 2], [0, 1], [2, 2]]]) == [3, 2, 1]
assert my_solution.vowelStrings(**[['bzmxvzjxfddcuznspdcbwiojiqf', 'mwguoaskvramwgiweogzulcinycosovozppl', 'uigevazgbrddbcsvrvnngfrvkhmqszjicpieahs', 'uivcdsboxnraqpokjzaayedf', 'yalc', 'bbhlbmpskgxmxosft', 'vigplemkoni', 'krdrlctodtmprpxwditvcps', 'gqjwokkskrb', 'bslxxpabivbvzkozzvdaykaatzrpe', 'qwhzcwkchluwdnqjwhabroyyxbtsrsxqjnfpadi', 'siqbezhkohmgbenbkikcxmvz', 'ddmaireeouzcvffkcohxus', 'kjzguljbwsxlrd', 'gqzuqcljvcpmoqlnrxvzqwoyas', 'vadguvpsubcwbfbaviedr', 'nxnorutztxfnpvmukpwuraen', 'imgvujjeygsiymdxp', 'rdzkpk', 'cuap', 'qcojjumwp', 'pyqzshwykhtyzdwzakjejqyxbganow', 'cvxuskhcloxykcu', 'ul', 'axzscbjajazvbxffrydajapweci'], [[4, 4], [6, 17], [10, 17], [9, 18], [17, 22], [5, 23], [2, 5], [17, 21], [5, 17], [4, 8], [7, 17], [16, 19], [7, 12], [9, 20], [13, 23], [1, 5], [19, 19]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['sdhky', 'kqcljybkksifhmyuhorulktlglydmqmfasqaht', 'oesmrtgthzdwbgnpkcgh', 'pauhingxekhno', 'nkqkuuhjqesjpd', 'jmkmsiqbhtbqamxanbwr', 'abqzwssfthcliekxllsndxluku', 'sulfsxaqwjtrghcwtuwkbsrqo', 'pmsfgbeardurzkxlicwuiliabjfn', 'vgshnkmwghoam', 'bvzldcctkxlcltvbemdwyilohofhl', 'mqhapsekfwzanlbkhzofsohtxbhijmpdanjqvwe', 'nbtuuosftvtj', 'dmxqapmiyoewvtoscdkeihyfitgwrrfieaobqj', 'qabfrbbzkxfljeiztjkgntrmbxkkadwn', 'cgveyyxtvo', 'lwcqsp', 'gut', 'qx', 'chdgjtkhmkixozuogrlskmatarpuhrfn', 'kvgdzuygrnwewdwvpbeihh', 'upzadbdyymyvuteolyeerecnuptghlzs', 'nozeuuvteryojyokp', 'xjzefjsatogetko', 'tlnusyeyyqygwupc', 'mt'], [[24, 25], [12, 18], [24, 25], [22, 22], [18, 25], [11, 24], [18, 20], [18, 22], [10, 10], [12, 19], [16, 18], [1, 3], [18, 23]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['b', 'rmivyakd', 'kddwnexxssssnvrske', 'vceguisunlxtldqenxiyfupvnsxdubcnaucpoi', 'nzwdiataxfkbikbtsjvcbjxtr', 'wlelgybcaakrxiutsmwnkuyanvcjczenuyaiy', 'eueryyiayq', 'bghegfwmwdoayakuzavnaucpur', 'ukorsxjfkdojcxgjxgmxbghno', 'pmgbiuzcwbsakwkyspeikpzhnyiqtqtfyephqhl', 'gsjdpelkbsruooeffnvjwtsidzw', 'ugeqzndjtogxjkmhkkczdpqzwcu', 'ppngtecadjsirj', 'rvfeoxunxaqezkrlr', 'adkxoxycpinlmcvmq', 'gfjhpxlzmokcmvhjcrbrpfakspscmju', 'rgmzhaj', 'ychktzwdhfuruhpvdjwfsqjhztshcxdey', 'yifrzmmyzvfk', 'mircixfzzobcficujgbj', 'd', 'pxcmwnqknyfkmafzbyajjildngccadudfziknos', 'dxmlikjoivggmyasaktllgmfhqpyznc', 'yqdbiiqexkemebyuitve'], [[5, 21], [17, 22], [19, 23], [13, 15], [20, 23], [21, 23], [6, 20], [1, 8], [15, 20], [17, 22], [6, 6], [1, 2], [4, 11], [14, 23], [7, 10], [16, 22], [20, 22], [21, 22], [15, 18], [5, 16], [17, 23]]]) == [2, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 2, 0]
assert my_solution.vowelStrings(**[['kzizbfceyysfjbkckouoqyrnxiobp', 'tfqjcavpwpyjmclwzjtyfpybipmynlkw', 'lrztxdla', 'gdhqqtobnaxvqgdzco', 'gcbzd', 'nuj', 'vferffslesxzofmidouariwuicauehfowcnv', 'czzeglsa', 'q', 'bzizqhugxngbkhfyxn', 'slebsmaccedlxjknmglsyexnfduue', 'oewsysetdvrtnuuws', 'su', 'benfnmdcavczz', 'lhkiksxegfbwnbllutdqnadrjz', 'qgauywpihdvysiwpkkxhvoglgedptnxvq', 'ghxnufgrapwzyvfxqxrpgr', 'ax', 'vivkmjjpust', 'p', 'jfxfeerpnpywxbxaqy', 'ciqqvebziztmmxhqltxnoklrpkdryupce', 'hsrlhcjvuapzyxkumaqdsqtffxxbudt'], [[13, 19], [17, 17], [14, 22], [4, 21], [4, 10], [18, 19], [2, 20], [15, 19], [8, 12], [6, 18], [21, 21], [20, 20], [16, 22], [2, 2], [20, 21], [4, 8], [16, 17], [3, 13], [0, 10], [4, 14]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['cflrm', 'cijkmlbfqvndbejornojrskvtxmiuajzin', 'omjtganzobjimtwk', 'rmsiuvsxtmryvsrp', 'xszpzelpzowqnk', 'jgggpyjlpqdgvgespxlfejgu', 'mfknjktbypeocnrkirywkwcbztpoixwmfrs', 'narnyv', 'xgbcyiv', 'suoypywheeydwgudqfdvkyfpjr', 'ttcsqrhpf', 'vtrkdonyrl', 'gqtrejhozfobjyxcwsxlkxnteblin', 'vksousorhltzffzcknmqagc', 'kxonfcycdfoqlkqguqpaitfqz', 'frvdlchqktyxhrpvjqcwkwwmdvjrd', 'isjveznlsjalhrnvmedog', 'delwleatorqcmn', 'wr', 'cvtgojgdvyuemygfsrwwzwvpeccqpgkbbvljgk', 'zq', 'updwfiwtknzssr', 'yhlqgqxhjlkqbuhqlponeackg', 'wgkpgwsfgsvrlisfkyzdjsmevlljccud', 'y', 'wkmkskrhehdrizaiiwgwogelaaifonhcoh', 'gvrl', 'mxslvajycct', 'gjmpojlupzphnm', 'wsghewxiamusracsvevypoakmylaob', 'rssykhcam', 'taqvwukssbbiqjqtuhzoqq', 'erlzszzvppmjkxqeallbfijqevmbcyaq', 'anxrrekineex', 'mtthkpgt', 'bqvfy', 'ofwlbyjhbabwwmcdyoub', 'prfcm'], [[7, 22], [28, 36], [10, 27], [6, 14], [23, 34], [27, 35]]]) == [0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['qysocu', 'xnisoxgsdkujhjjadtsqddmmd', 'vwervizcudgedrguu', 'uzoaikzkhuxbzszqar', 'rzvuejyncmwpbhs', 'gap', 'ekpvxaowewrpzzjdukewfr', 'tawetkkelzvtqfbyxaxtceegx', 'ismdpgsjnmqyfhrkaaoyhvarkno'], [[7, 8], [2, 8], [0, 5], [3, 5], [6, 6], [3, 3], [2, 8], [7, 7], [7, 8], [7, 7], [7, 8], [7, 8], [8, 8], [0, 5], [8, 8], [6, 8], [1, 5], [2, 6], [2, 3], [1, 6], [3, 3], [0, 7], [7, 7], [8, 8], [2, 7], [7, 7], [4, 4], [4, 6], [2, 5], [5, 5], [5, 5], [1, 2], [4, 6], [5, 6]]]) == [1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['kqcwylmjlflugvmjulgldifenpserey'], [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['ebnnporwiufimntatuaoadwbxrtrt', 'xjjqnrjkkbto', 'tkubqyxihhxikigwlnkikxhsfxmhl', 'xeezqycyn', 'ewrdylevbatctcydoqjcmixffplhdvcxy', 'erhrezicc', 'b', 'lgildbphjsiechluqedoor', 'vsuvhhkaxvdvipmlpxkawyuektwwyq', 'xvirozecg', 'mxzreujgplnza', 'lvwtmnpkswiyoheshvyjjhgzvwayv', 'ykbonftzsuuv', 'tpbyufbbqpe', 'nozcjouwqrxup', 'o', 'bzvicojsvpvaglmveonqabc', 'jefoabkhvaikfnjgamzbvisoff', 'tihdokbjutzwmuukkol', 'rjbqfnmoccwhidzzqekaudnsrhkybggicvmvbgch'], [[7, 10], [6, 9], [12, 13], [17, 18], [5, 10], [12, 12], [17, 19], [1, 18], [13, 18], [3, 11], [6, 14], [9, 10], [3, 19], [13, 18], [17, 18], [5, 7], [3, 12], [9, 11], [15, 17], [7, 15], [18, 18], [2, 17]]]) == [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1]
assert my_solution.vowelStrings(**[['lyyzudvjdyltipmhkumetwg', 'lqphoab', 'nfueqyndjnldpwzeradnpgtxzcr', 'pxmiqfqknizxgusbvuacyhtgatqvszxsfk', 'nkpowilcdroztjzcflqshbhyfsleaorbjbffgo', 'tnzumynvbdfgdbopspllaqqq', 'sfporptloygrtvozznlcp', 'ibliaczsvcfrayatcrat', 'wnugyklmitopphickg', 'hxytsolgcyzoujwjjizwbni', 'tqbvvvvexhgaejgwbl', 'qpaaazfectkbcbgnupuipggtg', 'srjbzftoatzdsoollejrwtqfawtydzioau'], [[9, 10], [1, 3], [2, 10], [2, 8], [6, 6], [5, 9], [5, 5], [3, 12], [0, 5], [12, 12], [5, 6]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['jkjygdvedvucpoqqjmlkjigu', 'lcugrvkfelprpgadlzozvz', 'qfasfpmypzybewinlok', 'gylumjtiv', 'shjwqyfawpdgypouxkvwymxvmsdtkviu', 'ygspumyfetltvknrlie', 'hefpubdyohbovc', 'ipngcoobilmirudkr', 'zgtiszbdvvjipxvpoxcqfiodwcajwoqkicsuhy', 'fwlwankuyct', 'wqiggpoorgquciqzcwhocmxf', 'dsbmolgqcehlfqgm', 'rpvklkdpmupiwhhwzffpavltauoab', 'yhiaochtubjutdrwwncoofpvcew', 'gmpgfnmbfkylgwzewmgvooskstvbhprpuiqn', 'hngyz', 'gnhuiivfchcknikmwhyk', 'pmrzq', 'vgkfpukilsbyroacdqoewidhtmqhqgaslh', 'amqueewnjziywsgzbwyefcocfuwwyigpir', 'xxypvelajleseetxyw', 'hypbatrjgvshn', 'zblctzekosqgwauyykzcvkut', 'vdtkoalhcqlxxpourbftqkoafhfbjs', 'dfhfhblraeckwgkjecfbkthzn', 'oouufeegcgkqapsx', 'ohj', 'rrclfpujlehcawpwmmosnyealwqsyeoziqsrkezn', 'yprmmsrjmbitzmldrxbqfdrhcswp', 'yumevxlhbxblzczmfgambaylzevgfoaumdb', 'bbfwtgagyocsqwzwrwqfnhgebhwnncydzebyahr', 'zygayauiqvqshmzcghupstxojxgjbhzjwamfb', 'nbeqvcynubjmoznxzxjwiss', 'qwaxtqckjdxyysxssefuvebvyqxcpqjemiyhitz', 'rdoqiaxdj', 'dxjbswzwpamgfx', 'fjhhribecrxxdlzrijcmagbcjkwoxoawafeezla'], [[2, 34], [30, 33], [24, 28], [29, 34], [34, 36], [6, 30], [10, 28], [2, 30], [31, 34], [17, 30], [14, 15], [2, 22], [24, 31], [15, 34], [1, 35], [12, 30], [21, 27], [9, 34], [18, 35], [34, 36], [11, 24], [6, 28], [16, 28], [13, 15], [23, 36], [25, 27], [26, 34], [31, 31], [16, 29], [22, 34], [23, 36], [25, 30], [26, 36], [16, 16], [13, 27], [23, 26], [5, 25], [0, 24], [26, 29], [27, 30], [26, 31], [7, 7], [13, 33], [19, 21], [13, 22], [5, 18], [10, 17], [36, 36], [20, 29], [10, 17]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['adqbhlgnodwriduksjmkpftqvmiumqij', 'xzvwhwqvxqzjlqokjauapypfsznnp', 'rndbibrunaqupg', 'pnrhgzytzzhixsduff', 'pvwmhcttsfbclijfonpxikdzxqppkjgddydgrqry', 'oytsussafuarpocczkhfmqxph', 'mzcxatlnbyevzxqdpryreaujijxvumzpxzp', 'mhimrruswxpjxpeiwimjiysvjiwfktolmebema', 'eftrwex', 'jdwnflcfczy', 'qaygln', 'irvofhdtmi', 'gtxmbeuhvldxh', 'allmhrsmiwrwp', 'lslagyvtishaksgziqccupckqullwpu', 'edipbgtxzdcgxfgbcdzwgdcfqgdfwqcjoaqo', 'xssysowxy', 'qvyuzrmofvavwto', 'tyhnfacslpyaphcpxwydbgsyvzvpuqipumnrpmvh', 'ajveebaxuovdzsvgaptydfpvhkscmgajhxoghnzh', 'mskzezrfwqzllqufowcfmytva', 'rsgoq', 'nchmwboowjmrfqlggprhk', 'iplkgjvlzygdsafhglymienafnw', 'ugfqtbjhhqayydxaspqhrema', 'piogsxjuvdhmlffmueflhfqmdllsxbot', 'obqyapxbaiahkjttsvgwlwilzdothqd', 'zgntkotwmcdgwugjrfyg', 'znf', 'vemfljhfnmkwhctqfnbetdgfajmyiicq', 'rmqij', 'ctrdougcchjvmtgszkwbcbwvtwhu', 'wsfniovdljzsctyzjiiqlxvzqatuliygdibzldn', 'cwgzlkzobxhkdzqxqwwytyrty'], [[0, 15], [7, 9], [2, 14], [15, 19], [13, 23], [26, 32], [5, 16]]]) == [2, 0, 1, 1, 1, 0, 2]
assert my_solution.vowelStrings(**[['iudibb', 'suejjertqtckmzloneax', 'adwocnu', 'idwstzyhpmhbasdag', 'qfsnlums', 'zokfvsjeualkidcbydbcsdjypacppoueoghpvevp', 'cddephdgmufwpllzfockd', 'vqowwarakfflbsmwhzzjedbb', 'jmlukjrjrlokgypqhqopogrcihlafwuapnctjjj', 'sjfyacnqqcifisjiciuvqqwkkpfylxuyybgirds', 'hyfi', 'gmktyoc', 'dhvpwwzz', 'kwjxwvigcukmcbvoeejgdaylrosxira', 'elxdlsqtarlhpmcwjyv', 'mloiczxrlxmqyetykoiy', 'emejlyduwciherxfmohukc', 'ojhlfmgaalhbvcivtltgkviu', 'gqrhceguhccfbrnbpmxerfpyvxaw', 'wmhn', 'euxnspekzbtqomdpynwreveyekvj', 'kkfkksflarmaiuzzqoxtwnbbhehgcyehgnyadgls', 'txjfymocufymepgcmnsxfvldtkoagpadnfsxej', 'kftsm', 'hevhskgwskqdztvfviirwrhvdys', 'vjyfdernzdabdvwrjmundmviwmwdsqjibfrt', 'c', 'ufiimkekbmaffinctkexccpbkht', 'prntvrqrighrajmjxetxnpehllfvsrdhm', 'd', 'sbawxagjpqzhkjvfxrmsfbw', 'zetmyxgyadthxkzpgsycjin', 'spswgaestqizviowilhgn', 'zvilwxo', 'vgegoiydmpkgbpiorwxyupyklrvhdaftbci', 'udcfeffnwnruzhyffucxxs', 'gpvavrxaqumtqnivftptnebmmpgtawq', 'zbraiomlywxufrjxi'], [[21, 25], [21, 25], [7, 30], [22, 24], [17, 28], [25, 26], [20, 24], [24, 32], [18, 26], [22, 27], [36, 36], [7, 13], [30, 31], [20, 27], [16, 30], [10, 23], [13, 30], [33, 37], [29, 31], [31, 36], [8, 23], [30, 35], [32, 37], [2, 15], [10, 12], [20, 32], [31, 34], [33, 36], [2, 22], [9, 14], [16, 36], [10, 28], [10, 37], [29, 30], [22, 29], [34, 37], [20, 24], [37, 37], [33, 33]]]) == [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 2, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['hlruqkczmlttszvqdvnpofomx', 'znh', 'umlxgbo', 'tpirloqwbffqqznekgctaimdxjtzhjr', 'rmiwygiizotiitvdwqhfynlhrax', 'vwzznjjcuwvaduywibpgdupqplitrmdagcbyxkjn', 'e', 'iateezlzmsuqjealljagxzfuji', 'ku', 'qexhvripjpuspsujfrfrtift', 'twmgcdhudzboonemwgjhkpnymhahvzom', 'rspdilnfcddjnmpzyerkfaqjr', 'wceobkpgwcufvrtnvetag', 'ahujky', 'qfa', 'fnkkic', 'iqeusnplnnihjcat', 'ihtxbe', 'gnytogf', 'wtbwxm', 'mjbdcikaxkemmjqurfvbwcezgu', 'zrcmqaeqbsdluqfosfbe', 'f', 'uutsamkutlsewbmivkdrexstiykgqvyktcya', 'msoqjyngxfgyglhadmoorxmpowascvoodoq', 'udrgpxvlhrfsfvbuwpfx'], [[25, 25], [16, 25], [22, 22], [15, 19], [17, 20], [0, 11], [12, 18], [14, 22], [11, 17], [22, 24], [8, 25], [9, 19], [18, 22], [0, 23], [0, 11]]]) == [0, 2, 0, 1, 1, 3, 1, 1, 1, 1, 2, 1, 0, 5, 3]
assert my_solution.vowelStrings(**[['vjpusoeapvzdxxhmsfbdfjxvr', 'mqgzkybbvfrzv', 'nwlkndumbxbaaoibbmbftiayyqtyi', 'bwlx', 'bxaebmuznbldybexxcrsinqlo', 'btmrhswpavfmckxm', 'lmhrfxvgnywckjwzuqgglksk', 'xxwoxpk'], [[0, 5], [2, 5], [4, 4], [5, 7], [0, 0], [0, 3], [5, 5], [1, 2], [0, 3], [2, 4], [4, 7], [1, 6], [7, 7], [6, 6], [5, 5], [7, 7], [0, 0], [4, 5], [2, 7], [6, 7], [7, 7], [3, 5], [7, 7], [6, 7], [6, 7], [4, 7], [1, 6], [0, 0], [4, 7], [6, 6], [0, 6], [0, 5], [7, 7], [5, 7], [5, 7], [0, 0], [3, 6], [6, 7], [4, 6], [1, 1], [4, 4], [1, 2], [5, 5], [2, 5], [6, 6], [5, 5]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['wdvyujkiyn', 'irvzenhcktzis', 'jpzrjaysvgvhrolgt', 'jnjfwbjunncftitpshkwebuwevfurmkwfpeyc', 'xzsyajnoawddbxfqxsrvcrksqi', 'ocrgxkdwtfythbqkhyakaohajoqtmucbkgvac'], [[1, 2], [3, 4], [4, 5], [5, 5], [5, 5], [3, 4], [3, 5], [3, 4], [2, 3], [0, 1], [1, 4], [3, 3], [5, 5], [2, 2], [3, 4], [1, 1], [3, 4], [1, 1], [5, 5], [5, 5], [3, 5], [2, 4], [1, 2], [4, 4], [3, 3], [3, 5], [4, 4], [5, 5], [0, 1], [4, 5], [2, 4], [4, 5], [4, 5], [5, 5], [1, 3], [0, 1], [2, 4], [1, 1], [2, 2], [2, 4], [4, 4], [0, 2], [1, 4], [2, 4], [0, 4], [0, 4], [1, 5], [0, 0]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert my_solution.vowelStrings(**[['pdxrcutvvjgmsgwt', 'ffmgaughzdiowcipurh', 'hac', 'rlkqpncvlhmxswxzc', 'gkdkdnxffhhlxpihsmazaschnqxzy', 'nygcjswlauemfjudmmeirevblnltlnrchpymee', 'li', 'ceihxcoiqwdiughaguqqf', 'yalknuszrrmhlfscjcswkiumidhsadwoipkfi', 'ewhtfuuurkrdvlrcaifvr', 'ejfxswzxa', 'pdh', 'zfchnrrsnxipbmoysqlpguuoopvbpkxfilpzmvo', 'wkseztelfyrrkykjhh', 'jxetnjyabr', 'vosuxnmawelsdhnueewzdoxfkmqnblsv', 'dzbarfcdrnbht', 'ulpjo', 'vpu', 'essppvxi', 'rmhmbguhgrzfzzwqgwvxneueo', 'rlxufbdtulwnvowykgirsbpcwbibkhkinpbh', 'mvqbsfphbs', 'lepcbeiicqjywasvpqpdcuvxrolvlmitrmfim', 'dhwicdpbtmigvmcuaqkpkpbchpv', 'sjejysvtolgzqlgcsaq', 'ubheniqoibiczmvwphovghr', 'aqmrtaaejmoukyuzvtmzjewmwmvcbmvvcdre', 'abjdkpcfweakdqsdyrkdnspcvcbriecdfwroc', 'yrimnyqjx', 'rsj', 'gphyqsyuydgwwtswmcsgpo', 'fuyegcewpwkkgovcclhmzkkka', 'ibiicovpcghiskbsfza', 'pvfgucxmattwuljiudqatfvltqznwupxr'], [[12, 24], [15, 18], [26, 26], [4, 30], [20, 25], [19, 24], [8, 27], [1, 16], [5, 14], [2, 16], [11, 24], [26, 31], [7, 22], [4, 25], [24, 34], [30, 34], [3, 9], [10, 25], [26, 30], [13, 26], [19, 24], [5, 8], [29, 34], [1, 19], [10, 30], [8, 20], [9, 16], [7, 19], [9, 15], [10, 25], [23, 32], [6, 6], [24, 24], [26, 30], [16, 26], [32, 34], [5, 11], [22, 33], [4, 15], [2, 17], [32, 34], [25, 26], [4, 20], [4, 23], [19, 20], [24, 24]]]) == [2, 1, 0, 4, 0, 1, 4, 1, 1, 1, 2, 1, 3, 3, 2, 1, 0, 3, 1, 2, 1, 0, 1, 3, 4, 3, 1, 3, 1, 3, 1, 0, 0, 1, 2, 1, 1, 2, 1, 2, 1, 0, 3, 3, 1, 0]
assert my_solution.vowelStrings(**[['kviyfwtuuaedglemhgtkbqonjpcxhfxpf', 'efggogoqurtmaiqmxealfvosqgkvgyun', 'rsjtjmvamgxfmhcszrobrbdqwnunopbyjtu', 'cn', 'pvillikmtlogezdjqyrtxhbljpjqfjefki', 'juwrtyovdwbafuswixvlwipfhtxavvzrdyxtn', 'ztekbrpjewjqqsxtjpwnvguraaprxyddgudgn', 'teixnqgthpnoyjadurcglmqkajlhika', 'vdmptwozbiufklndtzqsgfjh', 'wcvkgdegzackpuubsxerrqelhuz', 'chwlshuqziggmwvcsermnujnpplihttv', 'cxldnlucddylmvikzhsruv', 'o', 'rshlmadebgajfnhnp', 'qkrxxqdppuocvl', 'mpbedbdiasfdcjxuwqphvlwijynfqdwrvdhtbv', 'jqgoadfjplly', 'qjzdodolhsbpkijomlyjkekgialocibhfwch', 'xucbiycgvbeqtqtegzolabqiwjkgvfomrzw', 'nhsdnztyzbvmflepneus', 'me', 'qpxks', 'akexnubpemhodpapyeturvpsixsrirpl', 'frajkqquvzsdmwxhoouysuhuczdlnzbnvgtf', 'curpeaveeopbexkwrteqonhdrwdeuevjlg', 'ktqhnczjxgixyqpcszoyfzorcusop', 'kmbtclpivdhrydenqmdflowfgrefgmrnhjdezg', 'hhfdalmqdilceommorakayfrxeuqdpyjpgupqolm', 'tqefxcuieylvekwbnzeqrrzijgexvpcgfnhrk', 'yipyqncxpsbriz', 'skqkkpdtjbevqjnyjzxfdeczsgkanpa', 'meovymx', 'wtgtjwnbsnljnbltm', 'vwpquradseboueebizzoqziseamgatfuy', 'nsfffwyaclpnrzautsgcsatwefijzuighjavk', 'godevqgrgwlbsnz', 'rgqapallbkvojducfojxfsqz'], [[8, 17], [17, 22], [2, 6], [24, 27], [4, 17], [24, 36], [28, 28], [1, 25], [16, 22], [4, 10], [36, 36], [6, 20], [27, 32], [13, 30], [24, 29], [2, 29], [0, 27], [32, 36], [0, 3], [0, 14], [18, 24], [1, 20], [7, 28], [14, 27], [15, 24], [35, 36], [31, 34], [23, 34], [0, 1], [4, 21], [18, 31], [33, 34], [28, 34], [25, 29], [16, 16], [16, 27], [11, 21]]]) == [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]
assert my_solution.vowelStrings(**[['joltuyuheoekaqmggmpdkynngneisl', 'zjvisze', 'kllebi', 'zijkcvimjrwmdxgzrogrejzyfhr', 'euecxiecok', 'zppcflaeswvcnugnqshkkhwaw', 'gsmopobusefrlzapu', 'btpeighitnayhmczlmak', 'akzyvnit', 'nnvudmufjhzsamyqnjsuiwjukwbxkbspqrqlvcu', 'vpaanntn', 'buxwhpxxwwsyxwjcdqbuzrx', 'vdfenhnaklyufjxgmiohhacgwhprzqklpb', 'qitvikjxygnxmrxkctxwziyfovcnk', 'jmhsaanfrndkvkrdepfqvnat', 'mqgdrvjigubizrfdkz', 'odvkaneairirvtqivzyongekboggbkbfkzmdwcut', 'bycedgrirsygqncdgiemfmr', 'jazjyhvcaeoejhbvsxlnbcofdpare', 'ododnsrx', 'hm', 'wyj'], [[20, 20], [2, 8], [16, 17], [15, 16], [17, 17], [3, 17], [4, 4], [18, 19], [6, 14], [9, 12], [15, 19], [10, 14], [4, 6], [12, 12], [16, 19], [7, 19], [1, 2], [21, 21], [2, 20], [19, 20], [16, 18], [21, 21], [11, 16], [6, 7], [20, 20], [6, 16], [10, 20]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

bzmxvzjxfddcuznspdcbwiojiqf mwguoaskvramwgiweogzulcinycosovozppl uigevazgbrddbcsvrvnngfrvkhmqszjicpieahs uivcdsboxnraqpokjzaayedf yalc bbhlbmpskgxmxosft vigplemkoni krdrlctodtmprpxwditvcps gqjwokkskrb bslxxpabivbvzkozzvdaykaatzrpe qwhzcwkchluwdnqjwhabroyyxbtsrsxqjnfpadi siqbezhkohmgbenbkikcxmvz ddmaireeouzcvffkcohxus kjzguljbwsxlrd gqzuqcljvcpmoqlnrxvzqwoyas vadguvpsubcwbfbaviedr nxnorutztxfnpvmukpwuraen imgvujjeygsiymdxp rdzkpk cuap qcojjumwp pyqzshwykhtyzdwzakjejqyxbganow cvxuskhcloxykcu ul axzscbjajazvbxffrydajapweci

sdhky kqcljybkksifhmyuhorulktlglydmqmfasqaht oesmrtgthzdwbgnpkcgh pauhingxekhno nkqkuuhjqesjpd jmkmsiqbhtbqamxanbwr abqzwssfthcliekxllsndxluku sulfsxaqwjtrghcwtuwkbsrqo pmsfgbeardurzkxlicwuiliabjfn vgshnkmwghoam bvzldcctkxlcltvbemdwyilohofhl mqhapsekfwzanlbkhzofsohtxbhijmpdanjqvwe nbtuuosftvtj dmxqapmiyoewvtoscdkeihyfitgwrrfieaobqj qabfrbbzkxfljeiztjkgntrmbxkkadwn cgveyyxtvo lwcqsp gut qx chdgjtkhmkixozuogrlskmatarpuhrfn kvgdzuygrnwewdwvpbeihh upzadbdyymyvuteolyeerecnuptghlzs nozeuuvteryojyokp xjzefjsatogetko tlnusyeyyqygwupc mt

b rmivyakd kddwnexxssssnvrske vceguisunlxtldqenxiyfupvnsxdubcnaucpoi nzwdiataxfkbikbtsjvcbjxtr wlelgybcaakrxiutsmwnkuyanvcjczenuyaiy eueryyiayq bghegfwmwdoayakuzavnaucpur ukorsxjfkdojcxgjxgmxbghno pmgbiuzcwbsakwkyspeikpzhnyiqtqtfyephqhl gsjdpelkbsruooeffnvjwtsidzw ugeqzndjtogxjkmhkkczdpqzwcu ppngtecadjsirj rvfeoxunxaqezkrlr adkxoxycpinlmcvmq gfjhpxlzmokcmvhjcrbrpfakspscmju rgmzhaj ychktzwdhfuruhpvdjwfsqjhztshcxdey yifrzmmyzvfk mircixfzzobcficujgbj d pxcmwnqknyfkmafzbyajjildngccadudfziknos dxmlikjoivggmyasaktllgmfhqpyznc yqdbiiqexkemebyuitve

kzizbfceyysfjbkckouoqyrnxiobp tfqjcavpwpyjmclwzjtyfpybipmynlkw lrztxdla gdhqqtobnaxvqgdzco gcbzd nuj vferffslesxzofmidouariwuicauehfowcnv czzeglsa q bzizqhugxngbkhfyxn slebsmaccedlxjknmglsyexnfduue oewsysetdvrtnuuws su benfnmdcavczz lhkiksxegfbwnbllutdqnadrjz qgauywpihdvysiwpkkxhvoglgedptnxvq ghxnufgrapwzyvfxqxrpgr ax vivkmjjpust p jfxfeerpnpywxbxaqy ciqqvebziztmmxhqltxnoklrpkdryupce hsrlhcjvuapzyxkumaqdsqtffxxbudt

cflrm cijkmlbfqvndbejornojrskvtxmiuajzin omjtganzobjimtwk rmsiuvsxtmryvsrp xszpzelpzowqnk jgggpyjlpqdgvgespxlfejgu mfknjktbypeocnrkirywkwcbztpoixwmfrs narnyv xgbcyiv suoypywheeydwgudqfdvkyfpjr ttcsqrhpf vtrkdonyrl gqtrejhozfobjyxcwsxlkxnteblin vksousorhltzffzcknmqagc kxonfcycdfoqlkqguqpaitfqz frvdlchqktyxhrpvjqcwkwwmdvjrd isjveznlsjalhrnvmedog delwleatorqcmn wr cvtgojgdvyuemygfsrwwzwvpeccqpgkbbvljgk zq updwfiwtknzssr yhlqgqxhjlkqbuhqlponeackg wgkpgwsfgsvrlisfkyzdjsmevlljccud y wkmkskrhehdrizaiiwgwogelaaifonhcoh gvrl mxslvajycct gjmpojlupzphnm wsghewxiamusracsvevypoakmylaob rssykhcam taqvwukssbbiqjqtuhzoqq erlzszzvppmjkxqeallbfijqevmbcyaq anxrrekineex mtthkpgt bqvfy ofwlbyjhbabwwmcdyoub prfcm

qysocu xnisoxgsdkujhjjadtsqddmmd vwervizcudgedrguu uzoaikzkhuxbzszqar rzvuejyncmwpbhs gap ekpvxaowewrpzzjdukewfr tawetkkelzvtqfbyxaxtceegx ismdpgsjnmqyfhrkaaoyhvarkno

lyyzudvjdyltipmhkumetwg lqphoab nfueqyndjnldpwzeradnpgtxzcr pxmiqfqknizxgusbvuacyhtgatqvszxsfk nkpowilcdroztjzcflqshbhyfsleaorbjbffgo tnzumynvbdfgdbopspllaqqq sfporptloygrtvozznlcp ibliaczsvcfrayatcrat wnugyklmitopphickg hxytsolgcyzoujwjjizwbni tqbvvvvexhgaejgwbl qpaaazfectkbcbgnupuipggtg srjbzftoatzdsoollejrwtqfawtydzioau

vjpusoeapvzdxxhmsfbdfjxvr mqgzkybbvfrzv nwlkndumbxbaaoibbmbftiayyqtyi bwlx bxaebmuznbldybexxcrsinqlo btmrhswpavfmckxm lmhrfxvgnywckjwzuqgglksk xxwoxpk

wdvyujkiyn irvzenhcktzis jpzrjaysvgvhrolgt jnjfwbjunncftitpshkwebuwevfurmkwfpeyc xzsyajnoawddbxfqxsrvcrksqi ocrgxkdwtfythbqkhyakaohajoqtmucbkgvac

pdxrcutvvjgmsgwt ffmgaughzdiowcipurh hac rlkqpncvlhmxswxzc gkdkdnxffhhlxpihsmazaschnqxzy nygcjswlauemfjudmmeirevblnltlnrchpymee li ceihxcoiqwdiughaguqqf yalknuszrrmhlfscjcswkiumidhsadwoipkfi ewhtfuuurkrdvlrcaifvr ejfxswzxa pdh zfchnrrsnxipbmoysqlpguuoopvbpkxfilpzmvo wkseztelfyrrkykjhh jxetnjyabr vosuxnmawelsdhnueewzdoxfkmqnblsv dzbarfcdrnbht ulpjo vpu essppvxi rmhmbguhgrzfzzwqgwvxneueo rlxufbdtulwnvowykgirsbpcwbibkhkinpbh mvqbsfphbs lepcbeiicqjywasvpqpdcuvxrolvlmitrmfim dhwicdpbtmigvmcuaqkpkpbchpv sjejysvtolgzqlgcsaq ubheniqoibiczmvwphovghr aqmrtaaejmoukyuzvtmzjewmwmvcbmvvcdre abjdkpcfweakdqsdyrkdnspcvcbriecdfwroc yrimnyqjx rsj gphyqsyuydgwwtswmcsgpo fuyegcewpwkkgovcclhmzkkka ibiicovpcghiskbsfza pvfgucxmattwuljiudqatfvltqznwupxr


# House Robber IV

There are several consecutive houses along a street, each of which has some money inside. There is also a robber, who wants to steal money from the homes, but he **refuses to steal from adjacent homes**.

The **capability** of the robber is the maximum amount of money he steals from one house of all the houses he robbed.

You are given an integer array `nums` representing how much money is stashed in each house. More formally, the `ith` house from the left has `nums[i]` dollars.

You are also given an integer `k`, representing the **minimum** number of houses the robber will steal from. It is always possible to steal at least `k` houses.

Return *the **minimum** capability of the robber out of all the possible ways to steal at least* `k` *houses*.

**Example 1:**

```

**Input:** nums = [2,3,5,9], k = 2
**Output:** 5
**Explanation:**
There are three ways to rob at least 2 houses:
- Rob the houses at indices 0 and 2. Capability is max(nums[0], nums[2]) = 5.
- Rob the houses at indices 0 and 3. Capability is max(nums[0], nums[3]) = 9.
- Rob the houses at indices 1 and 3. Capability is max(nums[1], nums[3]) = 9.
Therefore, we return min(5, 9, 9) = 5.

```

**Example 2:**

```

**Input:** nums = [2,7,9,3,1], k = 2
**Output:** 2
**Explanation:** There are 7 ways to rob the houses. The way which leads to minimum capability is to rob the house at index 0 and 4. Return max(nums[0], nums[4]) = 2.

```

**Constraints:**

* `1 <= nums.length <= 105`
* `1 <= nums[i] <= 109`
* `1 <= k <= (nums.length + 1)/2`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def minCapability(self, nums: List[int], k: int) -> int:
```

my_solution = Solution()

assert my_solution.minCapability(**[[2, 3, 5, 9], 2]) == 5
assert my_solution.minCapability(**[[2, 7, 9, 3, 1], 2]) == 2
assert my_solution.minCapability(**[[2, 2], 1]) == 2
assert my_solution.minCapability(**[[7, 3, 9, 5], 2]) == 5
assert my_solution.minCapability(**[[1, 4, 5], 1]) == 1
assert my_solution.minCapability(**[[1], 1]) == 1
assert my_solution.minCapability(**[[7, 1, 8, 11], 1]) == 1
assert my_solution.minCapability(**[[4, 22, 11, 14, 25], 3]) == 25
assert my_solution.minCapability(**[[10, 15, 6, 2], 1]) == 2
assert my_solution.minCapability(**[[9, 25, 16, 6, 18], 1]) == 6
assert my_solution.minCapability(**[[3, 6, 6, 9], 2]) == 6
assert my_solution.minCapability(**[[7, 14, 3, 6], 1]) == 3
assert my_solution.minCapability(**[[4, 4], 1]) == 4
assert my_solution.minCapability(**[[2, 1], 1]) == 1
assert my_solution.minCapability(**[[9, 6, 2], 1]) == 2
assert my_solution.minCapability(**[[3, 4, 1], 1]) == 1
assert my_solution.minCapability(**[[4, 2], 1]) == 2
assert my_solution.minCapability(**[[9, 6, 20, 21, 8], 3]) == 20
assert my_solution.minCapability(**[[13, 1, 13, 7], 2]) == 7
assert my_solution.minCapability(**[[2, 12, 11, 13], 2]) == 11


# Rearranging Fruits

You have two fruit baskets containing `n` fruits each. You are given two **0-indexed** integer arrays `basket1` and `basket2` representing the cost of fruit in each basket. You want to make both baskets **equal**. To do so, you can use the following operation as many times as you want:

* Chose two indices `i` and `j`, and swap the `ith`fruit of `basket1` with the `jth` fruit of `basket2`.
* The cost of the swap is `min(basket1[i],basket2[j])`.

Two baskets are considered equal if sorting them according to the fruit cost makes them exactly the same baskets.

Return *the minimum cost to make both the baskets equal or* `-1` *if impossible.*

**Example 1:**

```

**Input:** basket1 = [4,2,2,2], basket2 = [1,4,1,2]
**Output:** 1
**Explanation:** Swap index 1 of basket1 with index 0 of basket2, which has cost 1. Now basket1 = [4,1,2,2] and basket2 = [2,4,1,2]. Rearranging both the arrays makes them equal.

```

**Example 2:**

```

**Input:** basket1 = [2,3,4,1], basket2 = [3,2,5,1]
**Output:** -1
**Explanation:** It can be shown that it is impossible to make both the baskets equal.

```

**Constraints:**

* `basket1.length == basket2.length`
* `1 <= basket1.length <= 105`
* `1 <= basket1[i],basket2[i] <= 109`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def minCost(self, basket1: List[int], basket2: List[int]) -> int:
```


# Separate the Digits in an Array

Given an array of positive integers `nums`, return *an array* `answer` *that consists of the digits of each integer in* `nums` *after separating them in **the same order** they appear in* `nums`.

To separate the digits of an integer is to get all the digits it has in the same order.

* For example, for the integer `10921`, the separation of its digits is `[1,0,9,2,1]`.

**Example 1:**

```

**Input:** nums = [13,25,83,77]
**Output:** [1,3,2,5,8,3,7,7]
**Explanation:**
- The separation of 13 is [1,3].
- The separation of 25 is [2,5].
- The separation of 83 is [8,3].
- The separation of 77 is [7,7].
answer = [1,3,2,5,8,3,7,7]. Note that answer contains the separations in the same order.

```

**Example 2:**

```

**Input:** nums = [7,1,3,9]
**Output:** [7,1,3,9]
**Explanation:** The separation of each integer in nums is itself.
answer = [7,1,3,9].

```

**Constraints:**

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

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def separateDigits(self, nums: List[int]) -> List[int]:
```


# Maximum Number of Integers to Choose From a Range I

You are given an integer array `banned` and two integers `n` and `maxSum`. You are choosing some number of integers following the below rules:

* The chosen integers have to be in the range `[1, n]`.
* Each integer can be chosen **at most once**.
* The chosen integers should not be in the array `banned`.
* The sum of the chosen integers should not exceed `maxSum`.

Return *the **maximum** number of integers you can choose following the mentioned rules*.

**Example 1:**

```

**Input:** banned = [1,6,5], n = 5, maxSum = 6
**Output:** 2
**Explanation:** You can choose the integers 2 and 4.
2 and 4 are from the range [1, 5], both did not appear in banned, and their sum is 6, which did not exceed maxSum.

```

**Example 2:**

```

**Input:** banned = [1,2,3,4,5,6,7], n = 8, maxSum = 1
**Output:** 0
**Explanation:** You cannot choose any integer while following the mentioned conditions.

```

**Example 3:**

```

**Input:** banned = [11], n = 7, maxSum = 50
**Output:** 7
**Explanation:** You can choose the integers 1, 2, 3, 4, 5, 6, and 7.
They are from the range [1, 7], all did not appear in banned, and their sum is 28, which did not exceed maxSum.

```

**Constraints:**

* `1 <= banned.length <= 104`
* `1 <= banned[i], n <= 104`
* `1 <= maxSum <= 109`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def maxCount(self, banned: List[int], n: int, maxSum: int) -> int:
```


# Maximize Win From Two Segments

There are some prizes on the **X-axis**. You are given an integer array `prizePositions` that is **sorted in non-decreasing order**, where `prizePositions[i]` is the position of the `ith` prize. There could be different prizes at the same position on the line. You are also given an integer `k`.

You are allowed to select two segments with integer endpoints. The length of each segment must be `k`. You will collect all prizes whose position falls within at least one of the two selected segments (including the endpoints of the segments). The two selected segments may intersect.

* For example if `k = 2`, you can choose segments `[1, 3]` and `[2, 4]`, and you will win any prize i that satisfies `1 <= prizePositions[i] <= 3` or `2 <= prizePositions[i] <= 4`.

Return *the **maximum** number of prizes you can win if you choose the two segments optimally*.

**Example 1:**

```

**Input:** prizePositions = [1,1,2,2,3,3,5], k = 2
**Output:** 7
**Explanation:** In this example, you can win all 7 prizes by selecting two segments [1, 3] and [3, 5].

```

**Example 2:**

```

**Input:** prizePositions = [1,2,3,4], k = 0
**Output:** 2
**Explanation:** For this example, **one choice** for the segments is [3, 3] and [4, 4], and you will be able to get 2 prizes.

```

**Constraints:**

* `1 <= prizePositions.length <= 105`
* `1 <= prizePositions[i] <= 109`
* `0 <= k <= 109`
* `prizePositions` is sorted in non-decreasing order.

.spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0;
}
.spoiler {overflow:hidden;}
.spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;}
.spoilerbutton[value="Show Message"] + .spoiler > div {margin-top:-500%;}
.spoilerbutton[value="Hide Message"] + .spoiler {padding:5px;}

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def maximizeWin(self, prizePositions: List[int], k: int) -> int:
```


# Count Distinct Numbers on Board

You are given a positive integer `n`, that is initially placed on a board. Every day, for `109` days, you perform the following procedure:

* For each number `x` present on the board, find all numbers `1 <= i <= n` such that `x % i == 1`.
* Then, place those numbers on the board.

Return *the number of **distinct** integers present on the board after* `109` *days have elapsed*.

**Note:**

* Once a number is placed on the board, it will remain on it until the end.
* `%` stands for the modulo operation. For example, `14 % 3` is `2`.

**Example 1:**

```

**Input:** n = 5
**Output:** 4
**Explanation:** Initially, 5 is present on the board.
The next day, 2 and 4 will be added since 5 % 2 == 1 and 5 % 4 == 1.
After that day, 3 will be added to the board because 4 % 3 == 1.
At the end of a billion days, the distinct numbers on the board will be 2, 3, 4, and 5.

```

**Example 2:**

```

**Input:** n = 3
**Output:** 2
**Explanation:**
Since 3 % 2 == 1, 2 will be added to the board.
After a billion days, the only two distinct numbers on the board are 2 and 3.

```

**Constraints:**

* `1 <= n <= 100`

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def distinctIntegers(self, n: int) -> int:
```

my_solution = Solution()

assert my_solution.distinctIntegers(**[5]) == 4
assert my_solution.distinctIntegers(**[3]) == 2
assert my_solution.distinctIntegers(**[1]) == 1
assert my_solution.distinctIntegers(**[2]) == 1
assert my_solution.distinctIntegers(**[4]) == 3
assert my_solution.distinctIntegers(**[6]) == 5
assert my_solution.distinctIntegers(**[7]) == 6
assert my_solution.distinctIntegers(**[8]) == 7
assert my_solution.distinctIntegers(**[9]) == 8
assert my_solution.distinctIntegers(**[10]) == 9
assert my_solution.distinctIntegers(**[11]) == 10
assert my_solution.distinctIntegers(**[12]) == 11
assert my_solution.distinctIntegers(**[13]) == 12
assert my_solution.distinctIntegers(**[14]) == 13
assert my_solution.distinctIntegers(**[15]) == 14
assert my_solution.distinctIntegers(**[16]) == 15
assert my_solution.distinctIntegers(**[17]) == 16
assert my_solution.distinctIntegers(**[18]) == 17
assert my_solution.distinctIntegers(**[19]) == 18
assert my_solution.distinctIntegers(**[20]) == 19


# Put Marbles in Bags

You have `k` bags. You are given a **0-indexed** integer array `weights` where `weights[i]` is the weight of the `ith` marble. You are also given the integer `k.`

Divide the marbles into the `k` bags according to the following rules:

* No bag is empty.
* If the `ith` marble and `jth` marble are in a bag, then all marbles with an index between the `ith` and `jth` indices should also be in that same bag.
* If a bag consists of all the marbles with an index from `i` to `j` inclusively, then the cost of the bag is `weights[i] + weights[j]`.

The **score** after distributing the marbles is the sum of the costs of all the `k` bags.

Return *the **difference** between the **maximum** and **minimum** scores among marble distributions*.

**Example 1:**

```

**Input:** weights = [1,3,5,1], k = 2
**Output:** 4
**Explanation:**
The distribution [1],[3,5,1] results in the minimal score of (1+1) + (3+1) = 6.
The distribution [1,3],[5,1], results in the maximal score of (1+3) + (5+1) = 10.
Thus, we return their difference 10 - 6 = 4.

```

**Example 2:**

```

**Input:** weights = [1, 3], k = 2
**Output:** 0
**Explanation:** The only distribution possible is [1],[3].
Since both the maximal and minimal score are the same, we return 0.

```

**Constraints:**

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

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def putMarbles(self, weights: List[int], k: int) -> int:
```


# Count Increasing Quadruplets

Given a **0-indexed** integer array `nums` of size `n` containing all numbers from `1` to `n`, return *the number of increasing quadruplets*.

A quadruplet `(i, j, k, l)` is increasing if:

* `0 <= i < j < k < l < n`, and
* `nums[i] < nums[k] < nums[j] < nums[l]`.

**Example 1:**

```

**Input:** nums = [1,3,2,4,5]
**Output:** 2
**Explanation:**
- When i = 0, j = 1, k = 2, and l = 3, nums[i] < nums[k] < nums[j] < nums[l].
- When i = 0, j = 1, k = 2, and l = 4, nums[i] < nums[k] < nums[j] < nums[l].
There are no other quadruplets, so we return 2.

```

**Example 2:**

```

**Input:** nums = [1,2,3,4]
**Output:** 0
**Explanation:** There exists only one quadruplet with i = 0, j = 1, k = 2, l = 3, but since nums[j] < nums[k], we return 0.

```

**Constraints:**

* `4 <= nums.length <= 4000`
* `1 <= nums[i] <= nums.length`
* All the integers of `nums` are **unique**. `nums` is a permutation.

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def countQuadruplets(self, nums: List[int]) -> int:
```

my_solution = Solution()

assert my_solution.countQuadruplets(**[[1, 3, 2, 4, 5]]) == 2
assert my_solution.countQuadruplets(**[[1, 2, 3, 4]]) == 0
assert my_solution.countQuadruplets(**[[2, 5, 3, 1, 4]]) == 0
assert my_solution.countQuadruplets(**[[1, 3, 5, 2, 4]]) == 1
assert my_solution.countQuadruplets(**[[2, 4, 1, 3]]) == 0
assert my_solution.countQuadruplets(**[[3, 9, 5, 4, 8, 2, 1, 10, 7, 6]]) == 7
assert my_solution.countQuadruplets(**[[1, 7, 6, 5, 8, 3, 2, 4]]) == 4
assert my_solution.countQuadruplets(**[[9, 8, 5, 4, 2, 1, 6, 3, 7, 10]]) == 4
assert my_solution.countQuadruplets(**[[5, 2, 4, 1, 3]]) == 0
assert my_solution.countQuadruplets(**[[5, 3, 2, 4, 1]]) == 0
assert my_solution.countQuadruplets(**[[7, 2, 8, 9, 6, 4, 5, 1, 3]]) == 0
assert my_solution.countQuadruplets(**[[4, 2, 6, 3, 5, 7, 1, 8, 10, 9]]) == 12
assert my_solution.countQuadruplets(**[[3, 4, 6, 1, 7, 2, 8, 5, 9]]) == 11
assert my_solution.countQuadruplets(**[[9, 5, 3, 10, 6, 2, 4, 8, 7, 1]]) == 2
assert my_solution.countQuadruplets(**[[7, 4, 8, 9, 1, 3, 6, 2, 5]]) == 1
assert my_solution.countQuadruplets(**[[6, 1, 3, 9, 10, 7, 4, 8, 5, 2]]) == 2
assert my_solution.countQuadruplets(**[[1, 4, 2, 5, 3]]) == 1
assert my_solution.countQuadruplets(**[[3, 6, 4, 5, 8, 1, 7, 2]]) == 4
assert my_solution.countQuadruplets(**[[8, 7, 3, 4, 1, 6, 9, 5, 2]]) == 0
assert my_solution.countQuadruplets(**[[3, 5, 1, 4, 2, 6]]) == 2


# Alternating Digit Sum

You are given a positive integer `n`. Each digit of `n` has a sign according to the following rules:

* The **most significant digit** is assigned a **positive** sign.
* Each other digit has an opposite sign to its adjacent digits.

Return *the sum of all digits with their corresponding sign*.

**Example 1:**

```

**Input:** n = 521
**Output:** 4
**Explanation:** (+5) + (-2) + (+1) = 4.

```

**Example 2:**

```

**Input:** n = 111
**Output:** 1
**Explanation:** (+1) + (-1) + (+1) = 1.

```

**Example 3:**

```

**Input:** n = 886996
**Output:** 0
**Explanation:** (+8) + (-8) + (+6) + (-9) + (+9) + (-6) = 0.

```

**Constraints:**

* `1 <= n <= 109`

.spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0;
}
.spoiler {overflow:hidden;}
.spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;}
.spoilerbutton[value="Show Message"] + .spoiler > div {margin-top:-500%;}
.spoilerbutton[value="Hide Message"] + .spoiler {padding:5px;}

Please make sure your answer follows the type signature below:

```python3
class Solution:
    def alternateDigitSum(self, n: int) -> int:
```

my_solution = Solution()

assert my_solution.alternateDigitSum(**[521]) == 4
assert my_solution.alternateDigitSum(**[111]) == 1
assert my_solution.alternateDigitSum(**[886996]) == 0
assert my_solution.alternateDigitSum(**[4]) == 4
assert my_solution.alternateDigitSum(**[2]) == 2
assert my_solution.alternateDigitSum(**[7]) == 7
assert my_solution.alternateDigitSum(**[8]) == 8
assert my_solution.alternateDigitSum(**[10]) == 1
assert my_solution.alternateDigitSum(**[1]) == 1
assert my_solution.alternateDigitSum(**[5]) == 5
assert my_solution.alternateDigitSum(**[72]) == 5
assert my_solution.alternateDigitSum(**[64]) == 2
assert my_solution.alternateDigitSum(**[25]) == -3
assert my_solution.alternateDigitSum(**[56]) == -1
assert my_solution.alternateDigitSum(**[18]) == -7
assert my_solution.alternateDigitSum(**[81]) == 7
assert my_solution.alternateDigitSum(**[26]) == -4
assert my_solution.alternateDigitSum(**[40]) == 4
assert my_solution.alternateDigitSum(**[58]) == -3
assert my_solution.alternateDigitSum(**[97]) == 2