Find Maximum Total Amount (SDE I, Fungible :)
Problem Overview
- Select k consecutive bags to maximize total money from an infinite line, given non-overlapping segments of bag indices and their per-bag amount.
- Inputs/Outputs: segment is n×3 as [start, end, amount], k is the window length; return the maximum total modulo 1e9+7.
- Context: Amazon finance scenario where bags in segments hold money and bags outside hold zero.
- Company: Asked in Amazon interviews; a coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
