Tap here to switch tabs
Problem
Submissions

Problem: Sum of Total Strength of Wizards

Try to solve the Sum of Total Strength of Wizards problem.

Statement

You are given an integer array strength, where strength[i] denotes the strength of the ithi^{th} wizard.

A group of wizards is defined as a non empty contiguous subarray of strength. The total strength of a group is defined as the product of:

  1. The minimum strength among all wizards in the group.

  2. The total sum of the strengths of all wizards in the group.

Return the sum of the total strengths of all contiguous groups of wizards.

Note: Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq strength.length ≤105\leq 10^5

  • 1≤1 \leq strength[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Total Strength of Wizards

Try to solve the Sum of Total Strength of Wizards problem.

Statement

You are given an integer array strength, where strength[i] denotes the strength of the ithi^{th} wizard.

A group of wizards is defined as a non empty contiguous subarray of strength. The total strength of a group is defined as the product of:

  1. The minimum strength among all wizards in the group.

  2. The total sum of the strengths of all wizards in the group.

Return the sum of the total strengths of all contiguous groups of wizards.

Note: Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq strength.length ≤105\leq 10^5

  • 1≤1 \leq strength[i] ≤109\leq 10^9