C++ simplest, O(N), easy understand, no sorting
\n//We should keep 3 biggest and 2 smallest elements of the array\n//max product is either product of 3 bigger or 2 smallest(negatives) and the biggest\nclass S
```\n//We should keep 3 biggest and 2 smallest elements of the array\n//max product is either product of 3 bigger or 2 smallest(negatives) and the biggest\nclass Solution {\npublic:\n    int maximumProduct(vector<int>& nums) {\n        int max1=INT_MIN, max2=INT_MIN, max3=INT_MIN;\n        int min1=INT_MAX, min2=INT_MAX;\n        \n        for(int i=0;i<nums.size();++i){\n            if(nums[i]>=max3){\n\t\t\t    //max3 should always be the biggest\n\t\t\t\t// >= used because max2 can be equal to max3\n                max1=max2;\n                max2=max3;\n                max3=nums[i];\n            } else if(nums[i]>=max2){\n\t\t\t    //max2 should be second biggest\n\t\t\t\t//if current number is smaller compared to max3 but bigger than max2\n                max1=max2;\n                max2=nums[i];\n            } else if(nums[i]>max1){\n                max1=nums[i];\n            }\n            \n            if(nums[i]<=min1){\n\t\t\t    //same ideas, applied for minimum\n\t\t\t\t//min1 is the smallest, min2 - second smallest\n                min2=min1;\n                min1=nums[i];\n            } else if(nums[i]<min2){\n                min2=nums[i];\n            }\n        }\n        return max(max1*max2*max3, min1*min2*max3);\n    }\n};\n```
[]