This is a verified interview question from Amazon. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Maximum Consecutive Sum - Amazon Online Assessment ISM Dhanbad" covers key patterns like DP.
"In Amazon's financial team or 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. The problem is presented in the form of continuous segments. The objective is to select consecutive bags, in such a way that the total amount of money in these bags is maximized! The continuous segments provided to represent the amount of money in each bag do not intersect. Additionally, any bag included within a segment contains some amount of money, while bags not included in any segment are considered to have zero money. Formally, given a 2D array segment of size n x 3, where n represents the number of available segments, and an integer k representing the number of consecutive bags you take, and the 2D array segment represents the range of bags included in the segment [segment[i][0],segment[i][1]] and the amount of money inside the bags in the range segment[i][2]. Find the k consecutive bags with the maximum total amount of money, since the answer can be large, return it modulo (10^9 + 7)."
Join thousands of developers practicing for Amazon.