Buy or Sell
Start Timer
0:00:00
Given a list of stock_prices in ascending order by datetime, and their respective dates in list dts, write a function max_profit that outputs the max profit by buying and selling at a specific interval and start and end dates to buy and sell for max profit.
Example:
Input:
stock_prices = [10,5,20,32,25,12]
dts = [
'2019-01-01',
'2019-01-02',
'2019-01-03',
'2019-01-04',
'2019-01-05',
'2019-01-06',
]
def max_profit(stock_prices,dts) -> 27
Output:
def max_profit(stock_prices, dts) ->
(27, '2019-01-02', '2019-01-04')
.
.
.
.
.
.
.
.
.
Comments