LeetCode 122 Best Time to Buy and Sell Stock II 题解
1.题目:
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit.
You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times).
However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
题意:
输入一个数组,是每天股票的价格,进行买入卖出操作,返回你可以获得的最大利润。
2.解题思路:
贪心
3.代码
1 |
|