Skip to content

Practice Maximum Spending After Buying Items

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2931
LeetCode Problem

Maximum Spending After Buying Items

Problem Statement

Each row of values is a shop, with items ordered by nonincreasing value. On day d, starting at day 1, buy exactly one shop's rightmost remaining item for its value multiplied by d. Return the greatest total amount that can be spent buying every item from every shop.

Source: Maximum Spending After Buying Items on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
values = [[8,5,2],[6,4,1],[9,7,3]]
Output
285

# Example 2

Input
values = [[10,8,6,4,2],[9,7,5,3,2]]
Output
386

Constraints

1 <= m == values.length <= 10
1 <= n == values[i].length <= 10^4
1 <= values[i][j] <= 10^6
values[i] are sorted in non-increasing order.

Related LeetCode Problems

Practice more problems similar to Maximum Spending After Buying Items.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.