Code Room
CodingEasy
Question
A flash sale caps every item in the cart at a maximum price. Given the list of item prices and the cap, update the list so any price greater than the cap becomes exactly the cap, leaving cheaper items untouched, and return the list. Example: prices [12, 5, 30] with cap 10 become [10, 5, 10].
Implement
cap_prices(prices: list[int], cap: int) → list[int]Examples
in
[[12,5,30],10]out[10,5,10]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.
Learn the concepts
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.