Panda Guru LogoPanda
Guru

System Goodness | Google OA

Round 1

Questions: An water management system in made such that n tanks are connected linearly. The goodness of the i ^th tank is given by goodness[i]. The system goodness of a contiguous segment of tanks (i.e., a subsegment) is defined as the product of the number of tanks and the maximum goodness of the tanks in the segment.

Given the array goodness, find the sum of the system goodness of all the segments of the tanks. Since the answer can be large, report it modulo ( 10^9 + 7 ).

Example

Input:

n = 3 goodness = [3, 2, 3]

Output:

29

Function Description
Complete the function getSystemGoodnessSum in the editor below.


Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.