Coding interview:
You're given stocks on different days where
input_data =
[ [("5/1", 200), ("5/5", 100), ("5/8", 50)] # PLTR
[("5/1", 50), ("5/8", 100)] # MSFT
[("5/5", 50), ("5/8", 200)] ] # AMZN
Find the total sum of each day and use the previous values of each day if they are not included. For each day that a company does not have a price in, use the previous day's value to add to the sum so that the sum is always incrementing.
The result for input_data would be:
[("5/1", 300), ("5/5", 200), ("5/8", 350)]
Discussion
Loading comments…