🏆🔥✅O(N) Solution🏆🔥✅
\uD83D\uDE09Don\'t just watch & move away, also give an Upvote.\uD83D\uDE09\n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) 
# \uD83D\uDE09Don\'t just watch & move away, also give an Upvote.\uD83D\uDE09\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& nums) {\n        int ans = 0;\n        int minEle = nums[0];\n\n        for(auto i=1; i<size(nums); i++)\n        {\n            minEle = min(minEle, nums[i]);\n            ans = max(ans, nums[i]-minEle);\n        }\n\n<!-- \u2705Well before returning answer don\'t forget to UPVOTE.\u2705 -->\n        return ans == 0 ? -1:ans;\n    }\n};\n```\n![Leetcode Upvote.gif](https://assets.leetcode.com/users/images/8e4077f0-a213-42ca-ba23-630e76c3a3e9_1696160030.190374.gif)\n
['C', 'Python', 'C++', 'Java', 'JavaScript']