Python3 Two Solutions: O(nlogn) and O(n) time
O(nlogn) time O(1) space\n\npython\ndef maxProductDifference(self, nums: List[int]) -> int:\n        nums.sort()\n        return nums[-1]*nums[-2]-nums[0]*nums[
O(nlogn) time O(1) space\n\n```python\ndef maxProductDifference(self, nums: List[int]) -> int:\n        nums.sort()\n        return nums[-1]*nums[-2]-nums[0]*nums[1]\n```\n\nO(n) time O(1) space\n\n```python\ndef maxProductDifference(self, nums: List[int]) -> int:\n        min1 = min2 = float(\'inf\')\n        max1 = max2 = float(\'-inf\')\n        for n in nums:\n            if n <= min1:\n                min1, min2, = n, min1\n            elif n < min2:\n                min2 = n\n            if n >= max1:\n                max1, max2 = n, max1\n            elif n > max2:\n                max2 = n\n        return max1*max2-min1*min2\n```
['Python', 'Python3']