def maximumDifference(self, nums: List[int]) -> int:
	
	minVal = float('inf')
 
	diff = -1
	for n in nums:
		if n < minVal:
			minVal = min(n,minVal)
		else:
			currDiff = n - minVal
			if currDiff > 0:
				diff = max(diff, currDiff)
 
	return diff

trick

  • track the smallest number, and if the number is STRICTLY greater than the smallest num then we get the difference