Company: Coupa
Difficulty: medium
Sum of Subarray Problem Description You are given an array A of length N. For any subarray of array A, a subsequence of a subarray can be obtained by erasing some (possibly zero) elements from the subarray. You can erase any elements, not necessarily going successively. A subsequence of length K (where K >= 3) is considered good if every index i in subsequence (where 1 i - A i-1 | + | A i+1 - A i | = | A i-1 - A i+1 | The value of subarray S is defined as the maximum length of the good subsequence in the subarray S. Find the sum of the values of all the subarrays of array A. Function Description In the provided code snippet, implement the provided sumOfValues(...) method to find the sum of the values of all the subarrays of array A. You can write your code in the space below the phrase "WRITE YOUR LOGIC HERE".