Company: Salesforce SDE_23april
Difficulty: medium
You're given a CRM dashboard laid out as n rows and m columns of opportunity data values, and you may repeatedly perform this operation: Pick a row of the dashboard that still has values left. Remove one opportunity value from either the front or the back of that row. When the first value of a row is removed, the next value in line becomes the new first value. The same idea applies at the other end when the last value is removed. Work out the largest possible total of the opportunity values removed after carrying out exactly k operations. Note that the goal is to maximize what gets removed, not what's left behind in the dashboard. Note: The sum of removed opportunity values is to be returned rather than the sum of the remaining opportunity values. Example Consider n = 2, m = 3, k = 3 and dashboard = [[3, 7, 2], [4, 1, 5]]. The given dashboard is as follows: [ 3 7 2 ] [ 4 1 5 ] The following sequence of removal is optimal: Remove the first opportunity value from the first row, i.e., rem