bowang0911/leetcode huggingface dataset:
Frequency of the Most Frequent Element

The **frequency** of an element is the number of times it occurs in an array.

You are given an integer array `nums` and an integer `k`. In one operation, you can choose an index of `nums` and increment the element at that index by `1`.

Return _the **maximum possible frequency** of an element after performing **at most**_ `k` _operations_.

**Example 1:**

**Input:** nums = \[1,2,4\], k = 5
**Output:** 3
**Explanation:** Increment the first element three times and the second element two times to make nums = \[4,4,4\].
4 has a frequency of 3.

**Example 2:**

**Input:** nums = \[1,4,8,13\], k = 5
**Output:** 2
**Explanation:** There are multiple optimal solutions:
- Increment the first element three times to make nums = \[4,4,8,13\]. 4 has a frequency of 2.
- Increment the second element four times to make nums = \[1,8,8,13\]. 8 has a frequency of 2.
- Increment the third element five times to make nums = \[1,4,13,13\]. 13 has a frequency of 2.

**Example 3:**

**Input:** nums = \[3,9,6\], k = 2
**Output:** 1

**Constraints:**

*   `1 <= nums.length <= 105`
*   `1 <= nums[i] <= 105`
*   `1 <= k <= 105`
Longest Substring Of All Vowels in Order

A string is considered **beautiful** if it satisfies the following conditions:

*   Each of the 5 English vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`) must appear **at least once** in it.
*   The letters must be sorted in **alphabetical order** (i.e. all `'a'`s before `'e'`s, all `'e'`s before `'i'`s, etc.).

For example, strings `"aeiou "` and `"aaaaaaeiiiioou "` are considered **beautiful**, but `"uaeio "`, `"aeoiu "`, and `"aaaeeeooo "` are **not beautiful**.

Given a string `word` consisting of English vowels, return _the **length of the longest beautiful substring** of_ `word`_. If no such substring exists, return_ `0`.

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

**Example 1:**

**Input:** word =  "aeiaaioaaaaeiiiiouuuooaauuaeiu "
**Output:** 13
**Explanation:** The longest beautiful substring in word is  "aaaaeiiiiouuu " of length 13.

**Example 2:**

**Input:** word =  "aeeeiiiioooauuuaeiou "
**Output:** 5
**Explanation:** The longest beautiful substring in word is  "aeiou " of length 5.

**Example 3:**

**Input:** word =  "a "
**Output:** 0
**Explanation:** There is no beautiful substring, so return 0.

**Constraints:**

*   `1 <= word.length <= 5 * 105`
*   `word` consists of characters `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`.
Maximum Building Height

You want to build `n` new buildings in a city. The new buildings will be built in a line and are labeled from `1` to `n`.

However, there are city restrictions on the heights of the new buildings:

*   The height of each building must be a non-negative integer.
*   The height of the first building **must** be `0`.
*   The height difference between any two adjacent buildings **cannot exceed** `1`.

Additionally, there are city restrictions on the maximum height of specific buildings. These restrictions are given as a 2D integer array `restrictions` where `restrictions[i] = [idi, maxHeighti]` indicates that building `idi` must have a height **less than or equal to** `maxHeighti`.

It is guaranteed that each building will appear **at most once** in `restrictions`, and building `1` will **not** be in `restrictions`.

Return _the **maximum possible height** of the **tallest** building_.

**Example 1:**

**Input:** n = 5, restrictions = \[\[2,1\],\[4,1\]\]
**Output:** 2
**Explanation:** The green area in the image indicates the maximum allowed height for each building.
We can build the buildings with heights \[0,1,2,1,2\], and the tallest building has a height of 2.

**Example 2:**

**Input:** n = 6, restrictions = \[\]
**Output:** 5
**Explanation:** The green area in the image indicates the maximum allowed height for each building.
We can build the buildings with heights \[0,1,2,3,4,5\], and the tallest building has a height of 5.

**Example 3:**

**Input:** n = 10, restrictions = \[\[5,3\],\[2,5\],\[7,4\],\[10,3\]\]
**Output:** 5
**Explanation:** The green area in the image indicates the maximum allowed height for each building.
We can build the buildings with heights \[0,1,2,3,3,4,4,5,4,3\], and the tallest building has a height of 5.

**Constraints:**

*   `2 <= n <= 109`
*   `0 <= restrictions.length <= min(n - 1, 105)`
*   `2 <= idi <= n`
*   `idi` is **unique**.
*   `0 <= maxHeighti <= 109`
Next Palindrome Using Same Digits

You are given a numeric string `num`, representing a very large **palindrome**.

Return _the **smallest palindrome larger than**_ `num` _that can be created by rearranging its digits. If no such palindrome exists, return an empty string_ `" "`.

A **palindrome** is a number that reads the same backward as forward.

**Example 1:**

**Input:** num =  "1221 "
**Output:**  "2112 "
**Explanation:** The next palindrome larger than  "1221 " is  "2112 ".

**Example 2:**

**Input:** num =  "32123 "
**Output:**  " "
**Explanation:** No palindromes larger than  "32123 " can be made by rearranging the digits.

**Example 3:**

**Input:** num =  "45544554 "
**Output:**  "54455445 "
**Explanation:** The next palindrome larger than  "45544554 " is  "54455445 ".

**Constraints:**

*   `1 <= num.length <= 105`
*   `num` is a **palindrome**.
Replace All Digits with Characters

You are given a **0-indexed** string `s` that has lowercase English letters in its **even** indices and digits in its **odd** indices.

There is a function `shift(c, x)`, where `c` is a character and `x` is a digit, that returns the `xth` character after `c`.

*   For example, `shift('a', 5) = 'f'` and `shift('x', 0) = 'x'`.

For every **odd** index `i`, you want to replace the digit `s[i]` with `shift(s[i-1], s[i])`.

Return `s` _after replacing all digits. It is **guaranteed** that_ `shift(s[i-1], s[i])` _will never exceed_ `'z'`.

**Example 1:**

**Input:** s =  "a1c1e1 "
**Output:**  "abcdef "
**Explanation:** The digits are replaced as follows:
- s\[1\] -> shift('a',1) = 'b'
- s\[3\] -> shift('c',1) = 'd'
- s\[5\] -> shift('e',1) = 'f'

**Example 2:**

**Input:** s =  "a1b2c3d4e "
**Output:**  "abbdcfdhe "
**Explanation:** The digits are replaced as follows:
- s\[1\] -> shift('a',1) = 'b'
- s\[3\] -> shift('b',2) = 'd'
- s\[5\] -> shift('c',3) = 'f'
- s\[7\] -> shift('d',4) = 'h'

**Constraints:**

*   `1 <= s.length <= 100`
*   `s` consists only of lowercase English letters and digits.
*   `shift(s[i-1], s[i]) <= 'z'` for all **odd** indices `i`.
Seat Reservation Manager

Design a system that manages the reservation state of `n` seats that are numbered from `1` to `n`.

Implement the `SeatManager` class:

*   `SeatManager(int n)` Initializes a `SeatManager` object that will manage `n` seats numbered from `1` to `n`. All seats are initially available.
*   `int reserve()` Fetches the **smallest-numbered** unreserved seat, reserves it, and returns its number.
*   `void unreserve(int seatNumber)` Unreserves the seat with the given `seatNumber`.

**Example 1:**

**Input**
\[ "SeatManager ",  "reserve ",  "reserve ",  "unreserve ",  "reserve ",  "reserve ",  "reserve ",  "reserve ",  "unreserve "\]
\[\[5\], \[\], \[\], \[2\], \[\], \[\], \[\], \[\], \[5\]\]
**Output**
\[null, 1, 2, null, 2, 3, 4, 5, null\]

**Explanation**
SeatManager seatManager = new SeatManager(5); // Initializes a SeatManager with 5 seats.
seatManager.reserve();    // All seats are available, so return the lowest numbered seat, which is 1.
seatManager.reserve();    // The available seats are \[2,3,4,5\], so return the lowest of them, which is 2.
seatManager.unreserve(2); // Unreserve seat 2, so now the available seats are \[2,3,4,5\].
seatManager.reserve();    // The available seats are \[2,3,4,5\], so return the lowest of them, which is 2.
seatManager.reserve();    // The available seats are \[3,4,5\], so return the lowest of them, which is 3.
seatManager.reserve();    // The available seats are \[4,5\], so return the lowest of them, which is 4.
seatManager.reserve();    // The only available seat is seat 5, so return 5.
seatManager.unreserve(5); // Unreserve seat 5, so now the available seats are \[5\].

**Constraints:**

*   `1 <= n <= 105`
*   `1 <= seatNumber <= n`
*   For each call to `reserve`, it is guaranteed that there will be at least one unreserved seat.
*   For each call to `unreserve`, it is guaranteed that `seatNumber` will be reserved.
*   At most `105` calls **in total** will be made to `reserve` and `unreserve`.
Maximum Element After Decreasing and Rearranging

You are given an array of positive integers `arr`. Perform some operations (possibly none) on `arr` so that it satisfies these conditions:

*   The value of the **first** element in `arr` must be `1`.
*   The absolute difference between any 2 adjacent elements must be **less than or equal to** `1`. In other words, `abs(arr[i] - arr[i - 1]) <= 1` for each `i` where `1 <= i < arr.length` (**0-indexed**). `abs(x)` is the absolute value of `x`.

There are 2 types of operations that you can perform any number of times:

*   **Decrease** the value of any element of `arr` to a **smaller positive integer**.
*   **Rearrange** the elements of `arr` to be in any order.

Return _the **maximum** possible value of an element in_ `arr` _after performing the operations to satisfy the conditions_.

**Example 1:**

**Input:** arr = \[2,2,1,2,1\]
**Output:** 2
**Explanation:** 
We can satisfy the conditions by rearranging `arr` so it becomes `[1,2,2,2,1]`.
The largest element in `arr` is 2.

**Example 2:**

**Input:** arr = \[100,1,1000\]
**Output:** 3
**Explanation:** 
One possible way to satisfy the conditions is by doing the following:
1. Rearrange `arr` so it becomes `[1,100,1000]`.
2. Decrease the value of the second element to 2.
3. Decrease the value of the third element to 3.
Now `arr = [1,2,3], which` satisfies the conditions.
The largest element in `arr is 3.`

**Example 3:**

**Input:** arr = \[1,2,3,4,5\]
**Output:** 5
**Explanation:** The array already satisfies the conditions, and the largest element is 5.

**Constraints:**

*   `1 <= arr.length <= 105`
*   `1 <= arr[i] <= 109`
Closest Room

There is a hotel with `n` rooms. The rooms are represented by a 2D integer array `rooms` where `rooms[i] = [roomIdi, sizei]` denotes that there is a room with room number `roomIdi` and size equal to `sizei`. Each `roomIdi` is guaranteed to be **unique**.

You are also given `k` queries in a 2D array `queries` where `queries[j] = [preferredj, minSizej]`. The answer to the `jth` query is the room number `id` of a room such that:

*   The room has a size of **at least** `minSizej`, and
*   `abs(id - preferredj)` is **minimized**, where `abs(x)` is the absolute value of `x`.

If there is a **tie** in the absolute difference, then use the room with the **smallest** such `id`. If there is **no such room**, the answer is `-1`.

Return _an array_ `answer` _of length_ `k` _where_ `answer[j]` _contains the answer to the_ `jth` _query_.

**Example 1:**

**Input:** rooms = \[\[2,2\],\[1,2\],\[3,2\]\], queries = \[\[3,1\],\[3,3\],\[5,2\]\]
**Output:** \[3,-1,3\]
**Explanation:** The answers to the queries are as follows:
Query = \[3,1\]: Room number 3 is the closest as abs(3 - 3) = 0, and its size of 2 is at least 1. The answer is 3.
Query = \[3,3\]: There are no rooms with a size of at least 3, so the answer is -1.
Query = \[5,2\]: Room number 3 is the closest as abs(3 - 5) = 2, and its size of 2 is at least 2. The answer is 3.

**Example 2:**

**Input:** rooms = \[\[1,4\],\[2,3\],\[3,5\],\[4,1\],\[5,2\]\], queries = \[\[2,3\],\[2,4\],\[2,5\]\]
**Output:** \[2,1,3\]
**Explanation:** The answers to the queries are as follows:
Query = \[2,3\]: Room number 2 is the closest as abs(2 - 2) = 0, and its size of 3 is at least 3. The answer is 2.
Query = \[2,4\]: Room numbers 1 and 3 both have sizes of at least 4. The answer is 1 since it is smaller.
Query = \[2,5\]: Room number 3 is the only room with a size of at least 5. The answer is 3.

**Constraints:**

*   `n == rooms.length`
*   `1 <= n <= 105`
*   `k == queries.length`
*   `1 <= k <= 104`
*   `1 <= roomIdi, preferredj <= 107`
*   `1 <= sizei, minSizej <= 107`
Minimum Distance to the Target Element

Given an integer array `nums` **(0-indexed)** and two integers `target` and `start`, find an index `i` such that `nums[i] == target` and `abs(i - start)` is **minimized**. Note that `abs(x)` is the absolute value of `x`.

Return `abs(i - start)`.

It is **guaranteed** that `target` exists in `nums`.

**Example 1:**

**Input:** nums = \[1,2,3,4,5\], target = 5, start = 3
**Output:** 1
**Explanation:** nums\[4\] = 5 is the only value equal to target, so the answer is abs(4 - 3) = 1.

**Example 2:**

**Input:** nums = \[1\], target = 1, start = 0
**Output:** 0
**Explanation:** nums\[0\] = 1 is the only value equal to target, so the answer is abs(0 - 0) = 0.

**Example 3:**

**Input:** nums = \[1,1,1,1,1,1,1,1,1,1\], target = 1, start = 0
**Output:** 0
**Explanation:** Every value of nums is 1, but nums\[0\] minimizes abs(i - start), which is abs(0 - 0) = 0.

**Constraints:**

*   `1 <= nums.length <= 1000`
*   `1 <= nums[i] <= 104`
*   `0 <= start < nums.length`
*   `target` is in `nums`.
Splitting a String Into Descending Consecutive Values

You are given a string `s` that consists of only digits.

Check if we can split `s` into **two or more non-empty substrings** such that the **numerical values** of the substrings are in **descending order** and the **difference** between numerical values of every two **adjacent** **substrings** is equal to `1`.

*   For example, the string `s = "0090089 "` can be split into `[ "0090 ", "089 "]` with numerical values `[90,89]`. The values are in descending order and adjacent values differ by `1`, so this way is valid.
*   Another example, the string `s = "001 "` can be split into `[ "0 ", "01 "]`, `[ "00 ", "1 "]`, or `[ "0 ", "0 ", "1 "]`. However all the ways are invalid because they have numerical values `[0,1]`, `[0,1]`, and `[0,0,1]` respectively, all of which are not in descending order.

Return `true` _if it is possible to split_ `s`​​​​​​ _as described above__, or_ `false` _otherwise._

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

**Example 1:**

**Input:** s =  "1234 "
**Output:** false
**Explanation:** There is no valid way to split s.

**Example 2:**

**Input:** s =  "050043 "
**Output:** true
**Explanation:** s can be split into \[ "05 ",  "004 ",  "3 "\] with numerical values \[5,4,3\].
The values are in descending order with adjacent values differing by 1.

**Example 3:**

**Input:** s =  "9080701 "
**Output:** false
**Explanation:** There is no valid way to split s.

**Constraints:**

*   `1 <= s.length <= 20`
*   `s` only consists of digits.
Minimum Adjacent Swaps to Reach the Kth Smallest Number

You are given a string `num`, representing a large integer, and an integer `k`.

We call some integer **wonderful** if it is a **permutation** of the digits in `num` and is **greater in value** than `num`. There can be many wonderful integers. However, we only care about the **smallest-valued** ones.

*   For example, when `num = "5489355142 "`:
    *   The 1st smallest wonderful integer is `"5489355214 "`.
    *   The 2nd smallest wonderful integer is `"5489355241 "`.
    *   The 3rd smallest wonderful integer is `"5489355412 "`.
    *   The 4th smallest wonderful integer is `"5489355421 "`.

Return _the **minimum number of adjacent digit swaps** that needs to be applied to_ `num` _to reach the_ `kth` _**smallest wonderful** integer_.

The tests are generated in such a way that `kth` smallest wonderful integer exists.

**Example 1:**

**Input:** num =  "5489355142 ", k = 4
**Output:** 2
**Explanation:** The 4th smallest wonderful number is  "5489355421 ". To get this number:
- Swap index 7 with index 8:  "5489355142 " ->  "5489355412 "
- Swap index 8 with index 9:  "5489355412 " ->  "5489355421 "

**Example 2:**

**Input:** num =  "11112 ", k = 4
**Output:** 4
**Explanation:** The 4th smallest wonderful number is  "21111 ". To get this number:
- Swap index 3 with index 4:  "11112 " ->  "11121 "
- Swap index 2 with index 3:  "11121 " ->  "11211 "
- Swap index 1 with index 2:  "11211 " ->  "12111 "
- Swap index 0 with index 1:  "12111 " ->  "21111 "

**Example 3:**

**Input:** num =  "00123 ", k = 1
**Output:** 1
**Explanation:** The 1st smallest wonderful number is  "00132 ". To get this number:
- Swap index 3 with index 4:  "00123 " ->  "00132 "

**Constraints:**

*   `2 <= num.length <= 1000`
*   `1 <= k <= 1000`
*   `num` only consists of digits.
Minimum Interval to Include Each Query

You are given a 2D integer array `intervals`, where `intervals[i] = [lefti, righti]` describes the `ith` interval starting at `lefti` and ending at `righti` **(inclusive)**. The **size** of an interval is defined as the number of integers it contains, or more formally `righti - lefti + 1`.

You are also given an integer array `queries`. The answer to the `jth` query is the **size of the smallest interval** `i` such that `lefti <= queries[j] <= righti`. If no such interval exists, the answer is `-1`.

Return _an array containing the answers to the queries_.

**Example 1:**

**Input:** intervals = \[\[1,4\],\[2,4\],\[3,6\],\[4,4\]\], queries = \[2,3,4,5\]
**Output:** \[3,3,1,4\]
**Explanation:** The queries are processed as follows:
- Query = 2: The interval \[2,4\] is the smallest interval containing 2. The answer is 4 - 2 + 1 = 3.
- Query = 3: The interval \[2,4\] is the smallest interval containing 3. The answer is 4 - 2 + 1 = 3.
- Query = 4: The interval \[4,4\] is the smallest interval containing 4. The answer is 4 - 4 + 1 = 1.
- Query = 5: The interval \[3,6\] is the smallest interval containing 5. The answer is 6 - 3 + 1 = 4.

**Example 2:**

**Input:** intervals = \[\[2,3\],\[2,5\],\[1,8\],\[20,25\]\], queries = \[2,19,5,22\]
**Output:** \[2,-1,4,6\]
**Explanation:** The queries are processed as follows:
- Query = 2: The interval \[2,3\] is the smallest interval containing 2. The answer is 3 - 2 + 1 = 2.
- Query = 19: None of the intervals contain 19. The answer is -1.
- Query = 5: The interval \[2,5\] is the smallest interval containing 5. The answer is 5 - 2 + 1 = 4.
- Query = 22: The interval \[20,25\] is the smallest interval containing 22. The answer is 25 - 20 + 1 = 6.

**Constraints:**

*   `1 <= intervals.length <= 105`
*   `1 <= queries.length <= 105`
*   `intervals[i].length == 2`
*   `1 <= lefti <= righti <= 107`
*   `1 <= queries[j] <= 107`
Distinct Numbers in Each Subarray

Given an integer array `nums` and an integer `k`, you are asked to construct the array `ans` of size `n-k+1` where `ans[i]` is the number of **distinct** numbers in the subarray `nums[i:i+k-1] = [nums[i], nums[i+1], ..., nums[i+k-1]]`.

Return _the array_ `ans`.

**Example 1:**

**Input:** nums = \[1,2,3,2,2,1,3\], k = 3
**Output:** \[3,2,2,2,3\]
**Explanation:** The number of distinct elements in each subarray goes as follows:
- nums\[0:2\] = \[1,2,3\] so ans\[0\] = 3
- nums\[1:3\] = \[2,3,2\] so ans\[1\] = 2
- nums\[2:4\] = \[3,2,2\] so ans\[2\] = 2
- nums\[3:5\] = \[2,2,1\] so ans\[3\] = 2
- nums\[4:6\] = \[2,1,3\] so ans\[4\] = 3

**Example 2:**

**Input:** nums = \[1,1,1,1,2,3,4\], k = 4
**Output:** \[1,2,3,4\]
**Explanation:** The number of distinct elements in each subarray goes as follows:
- nums\[0:3\] = \[1,1,1,1\] so ans\[0\] = 1
- nums\[1:4\] = \[1,1,1,2\] so ans\[1\] = 2
- nums\[2:5\] = \[1,1,2,3\] so ans\[2\] = 3
- nums\[3:6\] = \[1,2,3,4\] so ans\[3\] = 4

**Constraints:**

*   `1 <= k <= nums.length <= 105`
*   `1 <= nums[i] <= 105`
Maximum Population Year

You are given a 2D integer array `logs` where each `logs[i] = [birthi, deathi]` indicates the birth and death years of the `ith` person.

The **population** of some year `x` is the number of people alive during that year. The `ith` person is counted in year `x`'s population if `x` is in the **inclusive** range `[birthi, deathi - 1]`. Note that the person is **not** counted in the year that they die.

Return _the **earliest** year with the **maximum population**_.

**Example 1:**

**Input:** logs = \[\[1993,1999\],\[2000,2010\]\]
**Output:** 1993
**Explanation:** The maximum population is 1, and 1993 is the earliest year with this population.

**Example 2:**

**Input:** logs = \[\[1950,1961\],\[1960,1971\],\[1970,1981\]\]
**Output:** 1960
**Explanation:** 
The maximum population is 2, and it had happened in years 1960 and 1970.
The earlier year between them is 1960.

**Constraints:**

*   `1 <= logs.length <= 100`
*   `1950 <= birthi < deathi <= 2050`
Maximum Distance Between a Pair of Values

You are given two **non-increasing 0-indexed** integer arrays `nums1`​​​​​​ and `nums2`​​​​​​.

A pair of indices `(i, j)`, where `0 <= i < nums1.length` and `0 <= j < nums2.length`, is **valid** if both `i <= j` and `nums1[i] <= nums2[j]`. The **distance** of the pair is `j - i`​​​​.

Return _the **maximum distance** of any **valid** pair_ `(i, j)`_. If there are no valid pairs, return_ `0`.

An array `arr` is **non-increasing** if `arr[i-1] >= arr[i]` for every `1 <= i < arr.length`.

**Example 1:**

**Input:** nums1 = \[55,30,5,4,2\], nums2 = \[100,20,10,10,5\]
**Output:** 2
**Explanation:** The valid pairs are (0,0), (2,2), (2,3), (2,4), (3,3), (3,4), and (4,4).
The maximum distance is 2 with pair (2,4).

**Example 2:**

**Input:** nums1 = \[2,2,2\], nums2 = \[10,10,1\]
**Output:** 1
**Explanation:** The valid pairs are (0,0), (0,1), and (1,1).
The maximum distance is 1 with pair (0,1).

**Example 3:**

**Input:** nums1 = \[30,29,19,5\], nums2 = \[25,25,25,25,25\]
**Output:** 2
**Explanation:** The valid pairs are (2,2), (2,3), (2,4), (3,3), and (3,4).
The maximum distance is 2 with pair (2,4).

**Constraints:**

*   `1 <= nums1.length, nums2.length <= 105`
*   `1 <= nums1[i], nums2[j] <= 105`
*   Both `nums1` and `nums2` are **non-increasing**.
Maximum Subarray Min-Product

The **min-product** of an array is equal to the **minimum value** in the array **multiplied by** the array's **sum**.

*   For example, the array `[3,2,5]` (minimum value is `2`) has a min-product of `2 * (3+2+5) = 2 * 10 = 20`.

Given an array of integers `nums`, return _the **maximum min-product** of any **non-empty subarray** of_ `nums`. Since the answer may be large, return it **modulo** `109 + 7`.

Note that the min-product should be maximized **before** performing the modulo operation. Testcases are generated such that the maximum min-product **without** modulo will fit in a **64-bit signed integer**.

A **subarray** is a **contiguous** part of an array.

**Example 1:**

**Input:** nums = \[1,2,3,2\]
**Output:** 14
**Explanation:** The maximum min-product is achieved with the subarray \[2,3,2\] (minimum value is 2).
2 \* (2+3+2) = 2 \* 7 = 14.

**Example 2:**

**Input:** nums = \[2,3,3,1,2\]
**Output:** 18
**Explanation:** The maximum min-product is achieved with the subarray \[3,3\] (minimum value is 3).
3 \* (3+3) = 3 \* 6 = 18.

**Example 3:**

**Input:** nums = \[3,1,5,6,4,2\]
**Output:** 60
**Explanation:** The maximum min-product is achieved with the subarray \[5,6,4\] (minimum value is 4).
4 \* (5+6+4) = 4 \* 15 = 60.

**Constraints:**

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