shlogg · Early preview
Md Ariful Haque @mah-shamim

Range Sum Of Sorted Subarray Sums Modulo 109 + 7

Given array nums, compute sum of all non-empty continuous subarrays, sort them, and return sum from index left to right (1-based) modulo 10^9 + 7.

1508. Range Sum of Sorted Subarray Sums
Medium
You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.
Return the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo 109 + 7.
Example 1:

Input: nums = [1,2,3,4], n = 4, left = 1, right = 5
Output: 13
Explanation: All subarray sums are 1, 3, 6, 10, 2, 5, 9, 3, 7, 4. After s...