Your question is Maximum Money in Consecutive Bags. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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.| 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 |