possible in this way also..
Intuition\nThe function uses two nested loops to compare each element with all subsequent elements. \n\n# Approach\n Describe your approach to solving the probl
# Intuition\nThe function uses two nested loops to compare each element with all subsequent elements. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n$$O(n^2)$$\n\n- Space complexity:\n$$O(n^2)$$\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumDifference = function(nums) {\n       let a=[];\n    for(let i=0;i<nums.length;i++){\n        for(let j=i+1;j<nums.length;j++){\n            if(nums[i]<nums[j]){\n                a.push(nums[j]-nums[i]);\n            }\n        }\n    }\n    \n    let b=Math.max(...a);\n\n    if(b==-Infinity){\n        return -1;\n    }else{\n         return b;\n    }\n   \n\n};\n```
['JavaScript']