Skip to content

Practice Reducing Dishes

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

Hard#1402
LeetCode Problem

Reducing Dishes

Problem Statement

A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time. Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i]. Return the maximum sum of like-time coefficient that the chef can obtain after preparing some amount of dishes. Dishes can be prepared in any order and the chef can discard some dishes to get this maximum value.

Source: Reducing Dishes on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
satisfaction = [-1,-8,0,5,-9]
Output
14

# Example 2

Input
satisfaction = [4,3,2]
Output
20

# Example 3

Input
satisfaction = [-1,-4,-5]
Output
0

Constraints

n == satisfaction.length
1 <= n <= 500
-1000 <= satisfaction[i] <= 1000

Related LeetCode Problems

Practice more problems similar to Reducing Dishes.

Review your practice with PhantomCodeAI

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