Trains the technique from
LeetCode 1402Reducing DishesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A showcase reel is cut together from a pile of clips. Clip i has been given a rating ratings[i] by the review panel, and a rating may be negative when the panel disliked the clip.
You choose which clips go into the reel and what order they play in. Any number of clips may be left out, including all of them. A clip that ends up in position p of the finished reel scores p * rating, where positions are numbered 1, 2, 3, ... over the clips that were actually included, so leaving a clip out shifts everything after it one position earlier. The reel's value is the sum of the scores of its clips, and an empty reel is worth 0.
Return the largest value a reel cut from these clips can have.
Example 1
Leave the clip rated -4 out and play the other two as 1 then 2. That reel scores 1 * 1 + 2 * 2 = 5.
Example 2
Include all three clips in the order -1, 5, 6. The scores are 1 * (-1), 2 * 5 and 3 * 6, which add up to 27.
Example 3
Every clip is rated below zero. Leaving all of them out gives an empty reel, worth 0.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def max_reel_value(ratings: list[int]) -> int:public int maxReelValue(int[] ratings)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.