Solution
C++ []\nclass Solution {\npublic:\n    int maximumProduct(vector<int>& nums) {\n        int max1 = INT32_MIN, max2 = INT32_MIN, max3 = INT32_MIN;\n        int m
```C++ []\nclass Solution {\npublic:\n    int maximumProduct(vector<int>& nums) {\n        int max1 = INT32_MIN, max2 = INT32_MIN, max3 = INT32_MIN;\n        int min1 = INT32_MAX, min2 = INT32_MAX;\n        for(int& num : nums) {\n            if(num > max1) {\n                max3 = max2, max2 = max1, max1 = num;\n            }\n            else if(num > max2) {\n                max3 = max2, max2 = num;\n            }\n            else if(num > max3) {\n                max3 = num;\n            }\n            if(num < min1) {\n                min2 = min1, min1 = num;\n            }\n            else if(num < min2) {\n                min2 = num;\n            }\n        }\n        return std::max(max1*max2*max3, max1*min1*min2);\n    }\n};\n```\n\n```Python3 []\nclass Solution:\n     def maximumProduct(self, nums):\n            a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)\n            return max(a[0] * a[1] * a[2], b[0] * b[1] * a[0])\n```\n\n```Java []\nclass Solution {\n    int maxi(int[] a,int n)\n    {\n        int max=(int)-9999999;\n        int f=-1;\n        for(int i=0;i<n;i++)\n        {\n            if(max<=a[i])\n            {\n                max=a[i];\n                f=i;\n            }\n        }\n        a[f]=(int)-9999999;\n        return max;\n    }\n    int min(int[] a,int n)\n    {\n        int max=(int)999999;\n        int f=-1;\n        for(int i=0;i<n;i++)\n        {\n            if(a[i]!=-9999999)\n            {\n                if(max>=a[i])\n            {\n                max=a[i];\n                f=i;\n            }\n            }\n        }\n        a[f]=(int)999999;\n        return max;\n    }\n    public int maximumProduct(int[] a) {\n        int n=a.length;\n        int aa=maxi(a,n);\n        int b=maxi(a,n);\n        int c=maxi(a,n);\n        if(n==3)\n        {\n            return aa*b*c;\n        }\n        int x=min(a,n);\n        int y=min(a,n);\n        if(n==4)\n        {\n            y=c;\n        }\n        return Math.max(aa*b*c,aa*x*y);\n    }\n}\n```\n
['C++', 'Java', 'Python3']