Skip to main content

Practice · 1 of 5

The Heaviest Stretch

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** Given n integers (possibly negative), print the maximum sum over all non-empty contiguous segments. **Constraints:** 1 ≤ n ≤ 200000; |a[i]| ≤ 10^9. **Output:** one integer. An O(n²) enumeration of all segments will not survive the largest test.

Back to lesson: Practice: Observation Drill — Five Hidden Structures