Maximum Money in K Consecutive Bags: In Amazon's financial team, an analyst is dealing with an infinite number of bags arranged in a line, each numbered from 1 to infinity. The task is to gather information about the amount of money in these bags, presented as continuous segments. The objective is to select consecutive bags with the maximum total amount of money. Return the answer modulo 10^9 + 7.
Asked in the OA stage. The input is stored in continuous segments in bag_segments, with K set in the query.
max_total_money.K = 5 for the consecutive-bag window length.start_bag and end_bag as inclusive endpoints.money_per_bag to every bag in its inclusive range.1000000007.| Column | Type | Description |
|---|---|---|
| segment_idPK | INT | Unique identifier for the continuous segment |
| start_bag | BIGINT | First bag number in the segment |
| end_bag | BIGINT | Last bag number in the segment |
| money_per_bag | BIGINT | Money contained in every bag in the segment |
| segment_label | VARCHAR(80) | Optional descriptive label for the segment |