Code Question 2 Amazon Web services has n servers. The cache optimization power of the ith server is power[i]. The cache optimization power of a group of contiguous servers [1,r] is defined as Power{,1 = (min powerfij) + (powerſij ) * 1=1 Find the sum of Power 1.r] for each possible contiguous group of servers. Since, the answer can be very large, return the answer modulo 1000000007(109 + 7). Example: power = (2, 3, 2, 1] There are n = 4 servers. The powers of contiguous groups of servers are: Power [0,0] = min([2]) * sum([2]) = 2 * 2 = 4 Power [0,1] = min([2, 3]) * sum([2, 3]) = 2 * 5 = 10 Power (0,2] = min([2, 3, 2]) * sum([2, 3, 2]) = 2 * 7 = 14 Power [2,3] = min([2, 3, 2, 1]) * sum( [2, 3, 2, 1]) = 1 * 8 = 8 Power[1,1] = min 1311 2. Code Question 2 Amazon Web services has n servers. The cache optimization power of the ith server is power[i]. The cache optimization power of a group of contiguous servers [1,r] is defined as Power ») = (min power(i) * (power[i]) Iisr i=1 Find the sum of Powerclrj for each possible contiguous group of servers. Since, the answer can be very large, return the answer modulo 1000000007(109 + 7). Example: power = (2, 3, 2, 1] There are n = 4 servers. The powers of contiguous groups of servers are: * Power [0,0] = min([2]) * sum([2]) = 2 * 2 = 4 Power [0,1] min([2, 3]) * sum([2, 3]) = 2 * 5 = 10 Power (0,2] = min ([2, 3, 2]) * sum([2, 3, 2]) = 2 * 7 = 14 Power (0,3] = min([2, 3, 2, 1]) * sum( [2, 3, 2, 1]) = 1 * 8 = 8 Power[1,1] = min (31) Function Description Complete the function findTotalPower function in the editor below. ALL 0 findTotalPower has the following parameters: int power[n]: the optimization power of each server 1 Returns: int: the sum of the powers of all possible contiguous groups of servers, modulo (109 + 7) 2 Constraints • 1sns 8*105 • 1 s power[i] = 109 ► Input Format For Custom Testing Sample Case 0 Sample Input For Custom Testing STDIN FUNCTION Input Format For Custom Testing The first line contains an integer, n, denoting the total number of servers. Each line i of the n subsequent lines (where os i



Answer :