Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can we sort the segments in a way to help solve the problem?
How can we dynamically keep track of the sum of the current segment(s)?
Solve with full IDE support and test cases