14 lines
424 B
Python
14 lines
424 B
Python
# https://leetcode.com/problems/maximum-difference-between-increasing-elements
|
|
|
|
from typing import List
|
|
|
|
class Solution:
|
|
def maximumDifference(self, nums: List[int]) -> int:
|
|
result = -1
|
|
curr_min = nums[0]
|
|
for i in range(1, len(nums)):
|
|
if nums[i] > curr_min:
|
|
result = max(result, nums[i] - curr_min)
|
|
curr_min = min(curr_min, nums[i])
|
|
return result
|
|
|