阅读背景:

LeetCode - 121. 买卖股票的最佳时机

来源:互联网 

121. 买卖股票的最佳时机

class Solution {
    public int maxProfit(int[] prices) {
        if (prices == null || prices.length == 0) {
            return 0;
        }
        int result = 0;
        int min = prices[0];
        for (int i = 1; i < prices.length; ++ i) {
            result = Math.max(prices[i] - min, result);
            min = Math.min(prices[i], min);
        }
        return result;
    }
}class Solution {
    publi



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: