Skip to content

Practice Maximum Amount of Money Robot Can Earn

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

Medium#3418
LeetCode Problem

Maximum Amount of Money Robot Can Earn

Problem Statement

A robot moves only right or down from the top-left to the bottom-right cell of coins. A nonnegative cell adds its value to the profit; a negative cell subtracts its absolute value. The robot may neutralize the loss at at most two negative cells along the path. Return the maximum possible final profit, which may be negative.

Source: Maximum Amount of Money Robot Can Earn on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
coins = [[0,1,-1],[1,-2,3],[2,-3,4]]
Output
8

# Example 2

Input
coins = [[10,10,10],[10,10,10]]
Output
40

Constraints

m == coins.length
n == coins[i].length
1 <= m, n <= 500
-1000 <= coins[i][j] <= 1000

Related LeetCode Problems

Practice more problems similar to Maximum Amount of Money Robot Can Earn.

Review your practice with PhantomCodeAI

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