✅ One Line Solution
Code #1 - The Fastest\nTime complexity: O(n). Space complexity: O(1).\n\nclass Solution:\n    def maxProduct(self, nums: List[int]) -> int:\n        return prod
# Code #1 - The Fastest\nTime complexity: $$O(n)$$. Space complexity: $$O(1)$$.\n```\nclass Solution:\n    def maxProduct(self, nums: List[int]) -> int:\n        return prod(x-1 for x in nlargest(2,nums))        \n```\n\n# Code #2 - The Least Efficient\nTime complexity: $$O(n*log(n))$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n    def maxProduct(self, nums: List[int]) -> int:\n        return prod(x-1 for x in sorted(nums)[-2:])\n```\n\n# Code #3 - Using Max() Twice\nTime complexity: $$O(n)$$. Space complexity: $$O(1)$$.\n```\nclass Solution:\n    def maxProduct(self, nums: List[int]) -> int:\n        return (max(chain(nums[:(i:=nums.index(max(nums)))], nums[i+1:]))-1)*(nums[i]-1)\n```\n\n# Code #4 - Using Argmax()\nTime complexity: $$O(n)$$. Space complexity: $$O(1)$$.\n```\nfrom numpy import argmax\nclass Solution:\n    def maxProduct(self, nums: List[int]) -> int:\n        return (max(chain(nums[:(i:=argmax(nums))], nums[i+1:]))-1)*(nums[i]-1)\n```
['Array', 'Sorting', 'Heap (Priority Queue)', 'Python', 'Python3']