2016. Maximum Difference Between Increasing Elements

Updated: 2024-03-12
1 min read
[]

On This Page

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