Simple python single pass solution
IntuitionWe need to track the smallest element and maxDifferenceApproachTravese throught the array and keep track of minimumElement and maximum difference.Compl
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We need to track the smallest element and maxDifference

# Approach
<!-- Describe your approach to solving the problem. -->
Travese throught the array and keep track of minimumElement and maximum difference.

# Complexity
- Time complexity: $$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ --> 

- Space complexity: $$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3
class Solution:
    def maximumDifference(self, nums: List[int]) -> int:
        # Initialize the minimum value as the first element of the array
        minVal = nums[0]
        # Initialize the maximum difference to -1 (default value if no valid difference is found)
        maxDiff = -1
        
        # Iterate through the list to find the maximum difference
        for num in nums:
            if num > minVal:
                # Calculate the difference between the current number and the minimum value seen so far
                diff = num - minVal
                # Update maxDiff if the new difference is larger
                maxDiff = max(maxDiff, diff)
            else:
                # Update minVal if a smaller number is encountered
                minVal = num
        
        # Return the maximum difference found (or -1 if no valid difference exists)
        return maxDiff
        
```
['Python3']