Trains the technique from
LeetCode 256Paint HouseThis 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 row of panels must each be given one of three finishes. prices[i][j] is what it costs to put finish j on panel i. Two panels standing next to each other may not share a finish.
Return the least it can cost to finish the whole row.
Example 1
Give the first panel the second finish for 3, the middle panel the third finish for 4 and the last panel the second finish for 2. No two neighbours match and the bill comes to 9.
Example 2
One panel has no neighbour, so the cheapest of its three finishes wins.
Example 3
Taking the cheapest finish on the first panel would push the second panel onto a finish costing 20. Paying 2 on the first panel lets the second cost 1.
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 min_cost(prices: list[list[int]]) -> int:public int minCost(int[][] prices)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.