Leetcode 121 Best Time to Buy and Sell Stock
Posted wgwyanfs
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Leetcode 121 Best Time to Buy and Sell Stock相关的知识,希望对你有一定的参考价值。
class Solution: # @param {integer[]} prices # @return {integer} def maxProfit(self, prices): if len(prices) <= 1: return 0 low = prices[0]; mostProfit = 0 for i in range(1, len(prices)): if prices[i] < low: low = prices[i] mostProfit = max(mostProfit, prices[i] - low) return mostProfit
以上是关于Leetcode 121 Best Time to Buy and Sell Stock的主要内容,如果未能解决你的问题,请参考以下文章