标签:temp price max turn tor class toc mamicode vector
题目思路
class Solution
{
public:
int maxProfit(vector<int>& prices)
{
int count = prices.size();
int profit = 0;
int tempprofit = 0;
for(int i = 0;i < count;i++)
{
for(int j = i + 1;j < count;j++)
{
tempprofit = prices[j] - prices[i];
if(tempprofit > profit)
{
profit = tempprofit;
}
}
}
return profit;
}
};
121. Best Time to Buy and Sell Stock
标签:temp price max turn tor class toc mamicode vector
原文地址:https://www.cnblogs.com/Manual-Linux/p/12005209.html