Solution: Sum of Subarray Ranges
C# solution for the Sum of Subarray Ranges problem using the Stacks pattern.
We'll cover the following...
We'll cover the following...
Statement
Given an integer array nums, consider every non empty contiguous subarray of nums. For each such subarray, define its range as the difference between its maximum element and its minimum element.
Return the sum of these ranges over all non empty contiguous subarrays of nums.
Note: A follow up asks whether you can solve this in
time.
Constraints:
...