Code RoomLargest buff card score
MediumPrep Room Coding #4896

Largest buff card score

CodingAlgorithms & data structuresMid–Senior~25 min

A card game applies a run of buff cards to one hero. Buff i multiplies the hero's score by multipliers[i] and then adds bonuses[i] on top. Every buff in the hand is played exactly once and you choose the order. Scores are whole numbers, every multiplier is at least 1, and every bonus is at least 1. The hero starts on base_score. Return the largest score the hand can end on. The two lists have the same length, and an empty hand leaves the hero on base_score. Playing the biggest multiplier first is not the answer, and neither is playing the biggest bonus first.

Implement
max_buffed_score(base_score: int, multipliers: list[int], bonuses: list[int]) → int
Examples
in[0,[2,3],[1,1]]out4
in[5,[1,4],[7,2]]out50
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 25 min
InputExpectedGot
[0,[2,3],[1,1]]4not run yetsample
[5,[1,4],[7,2]]50not run yetsample