Python O(n) time O(1) space
\nclass Solution:\n    def maximumProduct(self, nums: List[int]) -> int:\n        smallestTwo = [float(\'inf\')]*2\n        largestThree = [float(\'-inf\')]*3\n
```\nclass Solution:\n    def maximumProduct(self, nums: List[int]) -> int:\n        smallestTwo = [float(\'inf\')]*2\n        largestThree = [float(\'-inf\')]*3\n        for num in nums:\n            if num <= smallestTwo[0]:\n                smallestTwo[0] = num\n                smallestTwo.sort(reverse=True)\n            if num >= largestThree[0]:\n                largestThree[0] = num\n                largestThree.sort()\n        return max(smallestTwo[0]*smallestTwo[1]*largestThree[2], \n                   largestThree[0]*largestThree[1]*largestThree[2])\n```\n\nNote that the sorts take constant time since the sizes of `smallestTwo` and `largestThree` are constant.
['Python', 'Python3']