|Lothar Buchholz 30543abaf9||4 years ago|
|.idea||4 years ago|
|doc||4 years ago|
|gradle/wrapper||4 years ago|
|src||4 years ago|
|.gitignore||4 years ago|
|README.md||4 years ago|
|build.gradle||4 years ago|
|gradlew||4 years ago|
|gradlew.bat||4 years ago|
|settings.gradle||4 years ago|
Buy and Sell n-times
Given is the price-development of an arbitrary stock.
Suppose you have perfect knowledge and are able to buy and sell the stock multiple times. Write an algorithm that outputs the maximum profit that can be made by exactly n sales.
- 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
- Each buy must be made on another date after the previous sale
A blank-separated array of numbers.
The first number is the number of sales allowed.
All following numbers are stock-prices.
Each position symbolises the stock-price of a given day.
The maximum profit that can be made within that period by
- 2 <=
- 2 *
days with stock-prices<= 50
- 1 <=
3 12 11 13 9 12 8 14 13 15