使用单循环的python实现

#
# 
# @param prices int整型一维数组 
# @return int整型
#
class Solution:
    def maxProfit(self , prices ):
        # write code here
        min_price = 1347388
        max_rev = 0
        rev = 0
        for i in prices:
            min_price = min(min_price, i)
            rev = i-min_price
            max_rev = max(max_rev, rev)
        return max_rev