amazon intern sde vo Round1
263

Given a list of historic stock prices,
write a function that tells when you should have bought and sold to make the most profit.
You can only buy and sell once.
Example input:

1 [
2 {date: '2024-02-28', price: 130.0},
3 {date: '2024-03-01', price: 150.0},
4 {date: '2024-03-02' , price: 132.03,
5 {date: '2024-03-03' • price: 147.0},
6 {date: '2024-03-04' • price: 110.0},
7 {date: '2024-03-05' • price: 199.0},
8 {date: '2024-03-06' • price: 117.0},
9 {date: '2024-03-07', price: 100.0}
10

Goal:
Return the best buy date and best sell date to maximize profit.

Comments (0)