Greedy approch solution -->c++
class Solution {\npublic:\n    int maximumDifference(vector& nums) \n    {\n        int minidx=INT_MAX;\n        int ans=INT_MIN;\n        for(int i=0;i<nums.si
class Solution {\npublic:\n    int maximumDifference(vector<int>& nums) \n    {\n        int minidx=INT_MAX;\n        int ans=INT_MIN;\n        for(int i=0;i<nums.size();i++)\n        {\n            minidx=min(nums[i],minidx);\n            ans=max(ans,nums[i]-minidx);\n        }\n        if(ans==0)\n            return -1;\n        return ans;\n    }\n\t//it is similiar to https://leetcode.com/problems/best-time-to-buy-and-sell-stock/?envType=study-plan&id=level-1//\n};
[]