File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
algorithms/dynamic_programming/buy_sell_stock Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,19 @@ def max_profit_two_pointers(prices: List[int]) -> int:
3333 Space: O(1), no extra memory is used
3434 Time: O(n), where n is the size of the input list & we iterate through the list only once
3535 """
36+ def max_profit_two_pointers (prices : List [int ]) -> int :
37+ """
38+ Variation of max_profit using 2 pointers
39+ Complexity Analysis:
40+ Space: O(1), no extra memory is used
41+ Time: O(n), where n is the size of the input list & we iterate through the list only once
42+ """
43+ if prices is None or len (prices ) < 2 :
44+ return 0
45+
3646 number_of_prices = len (prices )
37- if prices is None or number_of_prices < 2 :
47+
48+ left , right = 0 , 1
3849 return 0
3950
4051 left , right = 0 , 1
You can’t perform that action at this time.
0 commit comments