Fetching algorithms...
Fetching algorithms...
Watch key transitions, pointers, and variables update step-by-step.
Read clean, documented implementations across multiple patterns.
Sketch diagrams on an infinite canvas and draft notes directly inline.
prices = [7,1,5,3,6,4]5prices = [7,6,4,3,1]0Track the minimum price seen so far and the maximum profit. For each price, calculate the profit if we sell at that price (current price - minimum price). Update the maximum profit if this profit is greater.
Time Complexity
Space Complexity