✅ One Line Solution
Code #1 - Fast\nTime complexity: O(n). Space complexity: O(1).\n\nclass Solution:\n    def maxProductDifference(self, A: List[int]) -> int:\n        return prod
# Code #1 - Fast\nTime complexity: $$O(n)$$. Space complexity: $$O(1)$$.\n```\nclass Solution:\n    def maxProductDifference(self, A: List[int]) -> int:\n        return prod(nlargest(2,A)) - prod(nsmallest(2,A))\n```\n\n# Code #2 - Slow\nTime complexity: $$O(n*log(n))$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n    def maxProductDifference(self, A: List[int]) -> int:\n        return prod((A:=sorted(A))[-2:]) - prod(A[:2])\n```
['Array', 'Sorting', 'Heap (Priority Queue)', 'Python', 'Python3']