https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ 12345678910111213 class Solution {public: int maxProfit(vector<int>& prices) { int n=prices.size(); int sum=0;//定义利润 for(int i=1;i<n;i++) { if(prices[i]-prices[i-1]>0) sum+=prices[i]-prices[i-1]; } return sum; }}; 赞微海报分享
近期评论