Best buy-sell profit
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]) → intExamples
in
[[8,3,6,4,9]]out6What 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
solution.py
InputExpectedGot
[[8,3,6,4,9]]6not run yetsample