C++ solution easy to understand
\n# Code\n\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& nums) {\n        int diff = -1;\n        for(int i=0;i<nums.size();i++){\n        
\n# Code\n```\nclass Solution {\npublic:\n    int maximumDifference(vector<int>& nums) {\n        int diff = -1;\n        for(int i=0;i<nums.size();i++){\n            int j = i + 1;\n            while(j < nums.size() && nums[i] < nums[j]){\n                if(nums[j] - nums[i] > diff){\n                    // cout<<diff<<" ";\n                    cout<<nums[j]-nums[i];\n                    diff = nums[j]-nums[i];\n                }\n                j++;\n            }\n        }\n        return diff;\n    }\n\n};\n```
['C++']