Skip to content

Practice Sum of Total Strength of Wizards

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2281
LeetCode Problem

Sum of Total Strength of Wizards

Problem Statement

For every nonempty contiguous subarray of strength, multiply its smallest value by the sum of all its values. Return the sum of these products over all subarrays, modulo 10^9 + 7.

Source: Sum of Total Strength of Wizards on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
strength = [1,3,1,2]
Output
44

# Example 2

Input
strength = [5,4,6]
Output
213

Constraints

1 <= strength.length <= 10^5
1 <= strength[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Sum of Total Strength of Wizards.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.