Trains the technique from
LeetCode 1856Maximum Subarray Min-ProductThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A run of couplings has strengths nums. For any contiguous stretch of it, the stretch's grade is the smallest strength in that stretch multiplied by the total of the strengths in it.
Return the largest grade over every non-empty contiguous stretch, modulo 10^9 + 7.
Example 1
The stretch 11, 7 has smallest strength 7 and totals 18, giving 126. Nothing beats it: reaching one further left drops the weakest link to 4, and reaching right drops it to 2. The best stretch on the other side, 9 and 6, only reaches 90.
Example 2
The three nines in the middle have smallest strength 9 and total 27, giving 243. Reaching out to either 1 would cut the weakest link to 1.
Example 3
The whole run is the best stretch, and its grade is a million times four million, which leaves this remainder once reduced.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def max_sum_min_product(nums: list[int]) -> int:public int maxSumMinProduct(int[] nums)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.