Best Java Solution O(n) : 0ms
Initiate & Declare min as the minimum integer possible.\n2.  Traverse the array nums using either for-each loop or general for loop.\n3.  Update min using Math.
1.  Initiate & Declare ```min``` as the minimum integer possible.\n2.  Traverse the array ```nums``` using either ```for-each``` loop or general ```for``` loop.\n3.  Update ```min``` using ```Math.min()``` comparing the ``` current element``` with the previous ```min```.\n4.  Update ```maxDiff``` using ```Math.max()``` comparing (the difference of ``` current element``` and  ```min``` ) with ```min```.\n5. If ```maxDiff == 0```,  that means no such i and j exists, return -1.\n6.  Else return maximum difference i.e ```maxDiff```.\n```\n    public int maximumDifference(int[] nums) {\n     int maxDiff = 0;\n     int min = Integer.MAX_VALUE;\n        \n        for(int element : nums){\n            min = Math.min(element,min);\n            maxDiff = Math.max(element-min,maxDiff);\n        }\n          if(maxDiff == 0)\n             return -1;\n\n        return maxDiff;\n    }\n```
[]