标签:最大 turn 个数 logs ++ div ice pre 统计
//给定数组,统计各个数字的最大和。
class Solution { public: int maxProfit(vector<int> &prices) { int res = 0; int n = prices.size(); for (int i = 0; i < n - 1; ++i) { if (prices[i] < prices[i + 1]) { res += prices[i + 1] - prices[i]; } } return res; } };
best-time-to-buy-and-sell-stock-ii
标签:最大 turn 个数 logs ++ div ice pre 统计
原文地址:http://www.cnblogs.com/xiuxiu55/p/6512803.html