C++| O(N^2)
\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& a) {\n        \n        int i,j,ans=0,n=a.size(),f=0;\n        \n        for(i=0;i<n;i++){\n
```\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& a) {\n        \n        int i,j,ans=0,n=a.size(),f=0;\n        \n        for(i=0;i<n;i++){\n            for(j=i+1;j<n;j++){\n                \n                if(a[j]>a[i]){\n                    f++;\n                    ans = max(ans, a[j]-a[i]);\n                }\n                \n            }\n        }\n        \n        if(f>0)\n        return ans;\n        \n        return -1;\n    }\n};\n```
[]