Bargain items first
A storefront wants bargain items shown before everything else. Given a list of item prices and a bargain limit, return the list rearranged so all prices strictly below the limit come first, followed by the rest — and within each of the two groups, the original relative order is preserved. Example: [8, 3, 10, 1, 5] with limit 6 becomes [3, 1, 5, 8, 10].
Implement
bargains_first(prices: list[int], limit: int) → list[int]Examples
in
[[8,3,10,1,5],6]out[3,1,5,8,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.
0:00 of about 11 min
solution.py
InputExpectedGot
[[8,3,10,1,5],6][3,1,5,8,10]not run yetsample