Interview Query

Buy or Sell

Have you seen this question before?

1. 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.


stock_prices = [10,5,20,32,25,12]
dts = [

def max_profit(stock_prices,dts) -> 27

2. Now, to make it harder, given the list of stock prices and date times in ascending order by datetime, write max_profit to output the profit and start and end dates to buy and sell for max profit.


def max_profit(stock_prices, dts) -> 
(27, '2019-01-02', '2019-01-04')
Next question: Out of Stock Inventory
Python 3.9.6
Loading editor