Best Time to Buy and Sell Stock Short python solution, O(n) runtime, O(1) space

来源:互联网 发布:大数据hadoop.pdf 编辑:程序博客网 时间:2024/05/20 06:07

问题很简单,要观察最大值和最小值的变化,我们需要保证更大值总出现在更小值的后面。


So, here is how I tackled it.

Instead of going forward, I scanned through the list of prices backward to store the current maximum number. Update the biggest difference along the way.

阅读全文
0 0
原创粉丝点击