标签:inf vector 图片 turn http src cto 数组 时机
题目:
解答:
1 class Solution { 2 public: 3 int maxProfit(vector<int>& prices) 4 { 5 int profit = 0; 6 for (int i = 1; i < prices.size(); i++) 7 { 8 int tmp = prices[i] - prices[i - 1]; 9 if (tmp > 0) 10 { 11 profit += tmp; 12 } 13 } 14 return profit; 15 } 16 };
标签:inf vector 图片 turn http src cto 数组 时机
原文地址:https://www.cnblogs.com/ocpc/p/12827027.html