Find the sum of max minus min over all subarrays.
Unlock detailed company stats for this questionUpgrade
For p levels, the statement used DSU to find the relative rank of each level and asked for the sum of abs(maximum - minimum) over all level arrangements, which reduces to sum(maximum - minimum) over all subarrays (Next Greater Element and Next Smaller Element, stack-based). N <= 1e5.
Community answers
No answers contributed by the community yet.
Related questions
Find the maximum sum subarray of size k.Find the minimum sum subarray of size k.Find the maximum subarray sum.Related courses

Course

Course
Course
