Code RoomBest buy-sell profit
EasyPrep Room Coding #635

Best buy-sell profit

CodingAlgorithms & data structuresEntry–Mid~10 min

A sneaker resale app shows a pair's projected listing price for each of the next n days. You may buy the pair on one day and sell it on any later day, at most one buy and one sell. Return the largest profit you can lock in, or 0 if every buy-sell combination loses money (you can always choose not to trade). Example: prices [8, 3, 6, 4, 9] gives profit 6 — buy at 3, sell at 9.

Implement
max_flip_profit(prices: list[int]) → int
Examples
in[[8,3,6,4,9]]out6
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 10 min
InputExpectedGot
[[8,3,6,4,9]]6not run yetsample