JavaScript O(n) solution
\nconst maximumDifference = nums => {\n    let res = -1;\n    let pointer1 = 0;\n    let pointer2 = 1;\n    \n    while (pointer2 <= nums.length - 1) {\n       
```\nconst maximumDifference = nums => {\n    let res = -1;\n    let pointer1 = 0;\n    let pointer2 = 1;\n    \n    while (pointer2 <= nums.length - 1) {\n        if (nums[pointer1] < nums[pointer2]) {\n            res = (nums[pointer2] - nums[pointer1]) > res \n                ? nums[pointer2] - nums[pointer1] \n                : res;\n        } else {\n            pointer1 = pointer2;\n        }\n        \n        pointer2++;\n    }\n    \n    return res;\n}\n```
['Two Pointers', 'JavaScript']