Practice Maximum Number of Points with Cost
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Choose exactly one cell from every row of points. Add the chosen cell values, then subtract the absolute difference of chosen column indices for every pair of consecutive rows. Return the greatest total score. Absolute difference means the nonnegative distance between those column indices.
Source: Maximum Number of Points with Cost on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
points = [[1,2,3],[1,5,1],[3,1,1]]
Output
9
# Example 2
Input
points = [[1,5],[2,3],[4,2]]
Output
11
Constraints
m == points.length
n == points[r].length
1 <= m, n <= 10^5
1 <= m * n <= 10^5
0 <= points[r][c] <= 10^5
Related LeetCode Problems
Practice more problems similar to Maximum Number of Points with Cost.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.