4MS 🏆 || JAVA ☕
Code


# Code
```java []
class Solution {
    public int maximumDifference(int[] nums) {
        int ans = -1;

        for (int i = 0; i < nums.length - 1; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (ans > (nums[j] - nums[i])) {
                    continue;
                } else {
                    if (nums[j] > nums[i]) {
                        ans = nums[j] - nums[i];
                    }
                }
            }
        }
        return ans;
    }
}
```
![7b3ed9e7-75a3-497e-85ef-237ed4f4fef7_1735690315.3860667.png](https://assets.leetcode.com/users/images/2d52e620-5103-4211-8f50-fff9faea4148_1737607619.072494.png)

['Java']