【leetcode】309. 最佳买卖股票时机含冷冻期
作者:互联网
#define max(a,b) ((a)>(b))?(a) :(b); int maxProfit(int* prices, int pricesSize){ if(pricesSize==0) return 0; int i, buy=-prices[0], sell=0, pre=0, tmp; for (i=1; i<pricesSize; i++){ tmp=sell; sell=max( sell, buy+prices[i] ); buy=max( buy, pre - prices[i] ); pre=tmp; } return sell; }
标签:sell,309,pre,int,pricesSize,prices,冷冻,leetcode 来源: https://www.cnblogs.com/ganxiang/p/14223168.html