Skip to content

catfireparty/buysell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

buysell

Max buy-sell profit problems.

background

Given a one-dimensional array of stock prices, what is the maximum profit that could have been achieved given a specific number of transactions?

You can only buy/sell one share at a time. You must alternate buying and selling (i.e. you can't hold shares)

e.g.

Given [1, 2, 3, 4, 5, 1, 3] as a stream of prices, with 4 transactions, the best profit you could make is 6 - buy on day 0, sell day 4, buy day 5, sell day 6.

About

Max buy-sell profit problems.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published