[Python3] O(N) and O(NlogN) solutions
The maximum can be one of below \n1) multiplying the three largest number;\n2) multiplying the largest number with two negative numbers largest in magnitude. \n
The maximum can be one of below \n1) multiplying the three largest number;\n2) multiplying the largest number with two negative numbers largest in magnitude. \n\nSo to loop through the list and keep track of the three largest and two smallest numbers is enough to compute the maximum. \n\n```\nclass Solution:\n    def maximumProduct(self, nums: List[int]) -> int:\n        max1 = max2 = max3 = float("-inf")\n        min1 = min2 = float("inf")\n        \n        for num in nums: \n            if num > max1:\n                max1, max2, max3 = num, max1, max2\n            elif num > max2:\n                max2, max3 = num, max2\n            elif num > max3:\n                max3 = num\n                \n            if num < min1:\n                min1, min2 = num, min1\n            elif num < min2:\n                min2 = num\n        \n        return max(max2*max3, min1*min2) * max1 \n```\n\nAlternatively, one could sort `nums`, and pick the larger one from `nums[0]*nums[1]*nums[-1]` and `nums[-3]*nums[-2]*nums[-1]`. \n```\nclass Solution:\n    def maximumProduct(self, nums: List[int]) -> int:\n        nums.sort()\n        return max(nums[0]*nums[1]*nums[-1], nums[-3]*nums[-2]*nums[-1])\n```\n\nPS: The test cases don\'t include all negative numbers as of June 29, 2020.
['Python3']