o(n) TC o(1) SC easy python solution 99.89 % acceptance
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n# Approach\n Describe your approach to solving the problem. \n\n Describe your appr
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n![image.png](https://assets.leetcode.com/users/images/0e7ec0d1-5552-4b01-b91f-bd50bfaddc8d_1729425015.8027806.png)\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n<!-- Describe your approach to solving the problem. -->\n- we will consider every upcoming element as greater and will try to find out the difference with the minimum element .\n- Will comapre the result if max then will update \n- we will update the minimum element as well. because current element might be the smallest\n- If final result is 0 then we will return -1  \n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def maximumDifference(self, nums: List[int]) -> int:\n        max_diff = 0\n        min_ele = nums[0]\n        for i in range(0, len(nums)):\n            max_diff = max(max_diff, nums[i]- min_ele)\n            min_ele = min(min_ele, nums[i])\n        if max_diff == 0:\n            return -1\n        return max_diff\n\n        \n```
['Python3']