def calculateMaximumConsecutiveSum(k: int, segment: list[list[int]]) -> int:
The round: the coding half of Amazon's online assessment (40 minutes in two reports), next to an AI-assisted debugging task. Six candidates reported it between May and the end of September 2026, and a round-up of June–September Amazon reports calls it the OA question it saw most often. Two candidates posted the prompt; one of them includes the constraints and the function signature. One candidate and a commenter on another report compare it to LeetCode 3413, Maximum Coins From K Consecutive Bags. Examples and constraints below are as reported; the prose is paraphrased.
Problem
Bags stand in a line, numbered from 1 to infinity. segment is an n × 3 array: every bag from segment[i][0] to segment[i][1] (both ends inclusive) holds segment[i][2] money. Segments never intersect, and a bag outside every segment holds 0. Choose k consecutive bags with the most money in total and return that total modulo 10^9 + 7.
def calculateMaximumConsecutiveSum(k: int, segment: list[list[int]]) -> int: ...
Constraints
1 ≤ n ≤ 2 * 10^51 ≤ k ≤ 10^91 ≤ segment[i][0] ≤ segment[i][1] ≤ 10^91 ≤ segment[i][2] ≤ 10^6Example
k = 5
segment = [[1, 4, 2], [6, 6, 5], [7, 7, 7], [9, 10, 1]]
Bag 1 2 3 4 5 6 7 8 9 10
Money 2 2 2 2 0 5 7 0 1 1
Bags 1-5: 8 2-6: 11 3-7: 16 4-8: 14 5-9: 13 6-10: 14
Output: 16
What the reports stress: bag numbers go up to 10^9, so you cannot build an array over every bag. One candidate's prefix-sum array passed 4 tests and hit memory errors on the hidden ones. The best window can cut a segment partway, at either end.
One candidate rates it hard if you have not seen it and medium-hard if you know the idea, with a long prompt whose story adds little. One candidate who used a per-bag prefix sum passed 4 tests, hit memory errors on the hidden ones and was rejected two days later. A commenter on another report counted more than ten test cases with large inputs. One candidate finished both OA tasks in a little over twenty minutes. A round-up of June–September Amazon reports calls this the OA question it saw most often, in at least three September OAs.
Also reported as Maximum Coins From K Consecutive Bags (LeetCode 3413)
The round: the coding half of Amazon's online assessment (40 minutes in two reports), next to an AI-assisted debugging task. Six candidates reported it between May and the end of September 2026, and a round-up of June–September Amazon reports calls it the OA question it saw most often. Two candidates posted the prompt; one of them includes the constraints and the function signature. One candidate and a commenter on another report compare it to LeetCode 3413, Maximum Coins From K Consecutive Bags. Examples and constraints below are as reported; the prose is paraphrased.
Problem
Bags stand in a line, numbered from 1 to infinity. segment is an n × 3 array: every bag from segment[i][0] to segment[i][1] (both ends inclusive) holds segment[i][2] money. Segments never intersect, and a bag outside every segment holds 0. Choose k consecutive bags with the most money in total and return that total modulo 10^9 + 7.
def calculateMaximumConsecutiveSum(k: int, segment: list[list[int]]) -> int: ...
Constraints
1 ≤ n ≤ 2 * 10^51 ≤ k ≤ 10^91 ≤ segment[i][0] ≤ segment[i][1] ≤ 10^91 ≤ segment[i][2] ≤ 10^6Example
k = 5
segment = [[1, 4, 2], [6, 6, 5], [7, 7, 7], [9, 10, 1]]
Bag 1 2 3 4 5 6 7 8 9 10
Money 2 2 2 2 0 5 7 0 1 1
Bags 1-5: 8 2-6: 11 3-7: 16 4-8: 14 5-9: 13 6-10: 14
Output: 16
What the reports stress: bag numbers go up to 10^9, so you cannot build an array over every bag. One candidate's prefix-sum array passed 4 tests and hit memory errors on the hidden ones. The best window can cut a segment partway, at either end.
What candidates report: It is LeetCode 3413 (Maximum Coins From K Consecutive Bags) with an Amazon story.; Bag numbers reach 10^9: one candidate's prefix-sum array over every bag passed 4 tests and ran out of memory on the hidden ones.; The window can cut a segment partway; one candidate warns about operator precedence in that product.; One candidate's outline: compress the coordinates to the segment ends, then prefix sums with binary search, or a sliding window.
Outcomes: The candidate whose prefix-sum array ran out of memory was rejected two days later.
Our note (standard LeetCode 3413 advice): Try the windows that start at a segment's left end and the windows that end at a segment's right end. Compare true totals and take the modulo once, at the end.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 57 Amazon questions, refreshed monthly from new candidate reports.