The cost of stock is given on each day. Find the maximum profit that you can make by buying and selling it on those days. There can be two conditions.
1. You can buy and sell only once
2. You can buy and sell multiple times
For example: If the given array is {100,180,260, 310, 40, 535, 695}
The maximum profit can be earned by buying on Day 0, selling on day 3. Again buy on day 4 and sell on Day 6.
1. You can buy and sell only once
2. You can buy and sell multiple times
For example: If the given array is {100,180,260, 310, 40, 535, 695}
The maximum profit can be earned by buying on Day 0, selling on day 3. Again buy on day 4 and sell on Day 6.
http://www.geeksforgeeks.org/stock-buy-sell/
ReplyDelete