题解 | #买卖股票的最好时机(一)#

买卖股票的最好时机(一)

https://www.nowcoder.com/practice/351b87e53d0d44928f4de9b6217d36bb

import sys
prices = [*map(int, sys.stdin.read().strip().split())]
n, prices = prices[0], prices[1:]

mi, mx = prices[0], -99999999999

for i, e in enumerate(prices[1:], start=1):
	mx = max(mx, e - mi)
	mi = min(mi, e)

print(max(0, mx))

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务