Leetcode 2281. Sum of Total Strength of Wizards
Compute the sum over all contiguous subarrays of (minimum element × sum of elements), which requires attributing each element’s contribution when it is the subarray minimum and aggregating many subarray sums efficiently. The typical solution uses a monotonic stack to find ranges where each element is the minimum combined with prefix-sum / prefix-of-prefix tricks to accumulate sums modulo 1e9+7.
Asked at:
Amazon
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late June, 2026
Amazon
Mid-level
Question was rephrased to use n servers, each with dedicated cache optimization power as power[i]. Cache optimization power of a group of contiguous servers [l, r] is product of minimum power p[i] in range l <= i <= r and sum of the subarray. Return the sum of Power for all possible contiguous groups, modulo 10^9 + 7
Hello Interview Premium
Your account is free and you can post anonymously if you choose.