Maximum Money in K Consecutive Bags

Asked at Amazon · Coding Questions · Difficulty: Hard · Last asked May 24, 2026

Bags on a number line carry money only inside non-overlapping segments; each `segment` is `[start, end, money_per_bag]`, and bags outside every segment hold 0. Choose `k` consecutive bag positions to maximize the total money, returned modulo `1_000_000_007`.

Loading the problem…