标签:ice cto param fit public 股票 price ram size
class Solution {
public:
    /**
     * @param prices: Given an integer array
     * @return: Maximum profit
     */
    int maxProfit(vector<int> &prices) {
        // write your code here
 if(prices.size() == 0){
            return 0;  
        }  
          
        int max = 0;  
        int cur = prices[0];  
        for(int j = 0; j < prices.size(); ++j){  
            if(prices[j] < cur){   
                cur = prices[j];  
            }else{ 
                int tmp = prices[j] - cur;  
                if(tmp > max){  
                    max = tmp;  
                }  
            }  
        }  
        return max;  
    }  
};  
标签:ice cto param fit public 股票 price ram size
原文地址:http://www.cnblogs.com/11111wzc0417/p/6522161.html