K-th Largest Contiguous Segment Sum
Asked at DRW · Coding Questions · Difficulty: Medium · Last asked Nov 23, 2026
An array of integers has `n * (n + 1) / 2` contiguous non-empty segments, and each one has a sum. Picture writing all of those sums down and ordering them from largest to smallest, keeping repeats. Your task is to return the value that ends up in position `k` of that list. Values may be negative, so a longer segment does not always have a larger sum.
Loading the problem…