forked from code-clash/buy-and-sell-twice
Added description and testdata
This commit is contained in:
33
README.md
33
README.md
@@ -0,0 +1,33 @@
|
||||
# Buy and Sell Twice
|
||||
|
||||
## Goal
|
||||
Given is the price-development of an arbitrary stock.
|
||||
|
||||

|
||||
|
||||
Suppose you have perfect knowledge and are able to buy and sell the stock **twice**.
|
||||
Write an algorithm that outputs the maximum profit that can be made.
|
||||
|
||||
* The price-development is given for an arbitrary number of days.
|
||||
* A stock can only be sold on the next day.
|
||||
* Stock-prices are given as integers
|
||||
* **The second buy must be made on another date after the first sale**
|
||||
|
||||
### Input
|
||||
A blank-separated array of stock-prices.
|
||||
|
||||
Each position symbolises the stock-price of a given day.
|
||||
|
||||
### Output
|
||||
The maximum profit that can be made within that day.
|
||||
|
||||
### Constraints
|
||||
* 4 <= `days with stock-prices` <= 50
|
||||
* 1 <= `stock-price` <= 2,147,483,647
|
||||
|
||||
### Example
|
||||
**Input:**
|
||||
`12 11 13 9 12 8 14 13 15`
|
||||
|
||||
**Output:**
|
||||
`10`
|
||||
Reference in New Issue
Block a user