2016. Maximum Difference Between Increasing Elements

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2016

class Solution:
    def maximumDifference(self, nums: List[int]) -> int:
        mi = inf
        res = -1
        for x in nums:
            if x > mi:
                res = max(res, x - mi)
            else:
                mi = x
        return res