This commit is contained in:
parent
839160479e
commit
e522ef06bd
1 changed files with 14 additions and 0 deletions
14
easy/maximum_difference_between_increasing_elements.py
Normal file
14
easy/maximum_difference_between_increasing_elements.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue