🧠 Before you code — what pattern fits?
Given prices[i] (price on day i) and a transaction fee, you may complete as many transactions as you like (pay the fee per transaction, hold at most one share). Return the maximum profit.
(prices=[1,3,2,8,4,9], fee=2) → 8
🎬 Video explanation · Algorithms Made Easy
Your solution runs against 2 unit tests, including edge and large-value cases.
Loading...
Test console · 2 unit tests
Submit your code to run it against all 2 unit tests. Results appear here.
JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.