Search
⌘K

Leetcode 1508. Range Sum of Sorted Subarray Sums

Compute the sum of the subarray sums that rank between left and right (1-indexed) after sorting all O(n^2) non-empty subarray sums of a positive-integer array. The challenge is to avoid generating and sorting all sums by using prefix sums and binary-search on sum thresholds with a two-pointer/counting technique to count and accumulate subarray sums efficiently (mod 1e9+7).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.