src.best_buysell_stock

Classes

Solution()

class src.best_buysell_stock.Solution[source][source]
maxProfit(prices: list[int]) int[source]

Thought process

  • The main idea is just that the find the maximum profit we just store the lowest price and compare this to all the other values

Notes

  • time complexity : \(O(n)\)

  • space complexity: \(O(1)\)