c++ simple solution || brute force and dp ;)
1)BRUTE FORCE\n\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& nums) {\nint ans=0;\nint count=0;\nfor(int i=0 ; i<nums.size() ; i++)\n{\n   
1)BRUTE FORCE\n```\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& nums) {\nint ans=0;\nint count=0;\nfor(int i=0 ; i<nums.size() ; i++)\n{\n    for(int j=i+1 ; j<nums.size() ; j++)\n    {\n        count=nums[j]-nums[i];\n        ans=max(ans, count);\n    }\n}\nreturn ans==0?-1:ans;\n    }\n};\n```\n2)DYNAMIC PROGRAMMING\n```\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& nums) {\nint ans=-1;\nint m=INT_MAX;\nfor(int i=0 ; i<nums.size() ; i++)\n{\n    m=min(m , nums[i]);\n    if(nums[i]>m) ans=max(ans , nums[i]-m);\n}\n        return ans;\n    }\n};\n```\n\nfound it helpful ? please upvote ;)
['Dynamic Programming', 'C']