O(N) time || O(1) space || faster than others
\n\n# Code\n\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& nums) {\n        //for each element store minimum in left of it\n        int min
\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& nums) {\n        //for each element store minimum in left of it\n        int mini=nums[0];\n        int res=INT_MIN;\n        for(int i=1;i<nums.size();i++){\n            res=max(nums[i]-mini,res);\n            mini=min(mini,nums[i]);\n        }\n        return (res==INT_MIN ||res<=0)?-1:res;\n    }\n};\n```
['C++']