LeetCode122:
    给定一个数组prices,其中 prices[i]是一支给定股票第i天的价格。
    设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。
    注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。

    1. class Solution {
    2. public int maxProfit(int[] prices) {
    3. int profit = 0;
    4. int len = prices.length;
    5. for (int i = 1; i < len; i++) {
    6. int temp = prices[i] - prices[i - 1];
    7. if (temp > 0) {
    8. profit += temp;
    9. }
    10. }
    11. return profit;
    12. }
    13. }