Code Room
CodingMediumcod-g1480
Subject Dynamic programming 1dLevel Entry–Mid~14 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

In a fighting game, each attack in your move list deals a fixed amount of damage, and you may repeat attacks freely. A finishing combo must deal exactly the boss's remaining health — no overkill. Given the list of distinct positive damage values and the boss health, return how many distinct ordered sequences of attacks deal exactly that total. The same attacks in a different order count as different combos. If health is 0, return 1 (the empty combo).

Implement
count_finishing_combos(damages: list[int], health: int) → int
Examples
in[[1,2],4]out5
in[[2,3],7]out3
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.