codebuddies / DailyAlgorithms

Do a problem. Create (or find) your problem in the issues. Paste a link to your solution. See others' solutions of the same problem.
12 stars 1 forks source link

[Practice] Given map of timestamps to stock prices for a single day... #22

Open lpatmo opened 5 years ago

lpatmo commented 5 years ago

How about this one? Given a map of timestamps to stock prices for a single day, return the best times to have bought and sold them respectively, and the total profit you would have earned.

Note: Yup, a dictionary of timestamps to stock prices, in Python terms you can assume it's like Dict[datetime, float] (that is, if datetimes are allowed as dictionary keys. If not assume they're strings that are easily parsed into datetime)

Assume it's for one day and for one stock