Time: O(n), Space: O(1)
Base: Maximum product of three numbers is possible only when all three numbers are positive or two numbers are negative and one is positive.\n\nApproach1: \n1. 
Base: Maximum product of three numbers is possible only when all three numbers are positive or two numbers are negative and one is positive.\n\nApproach1: \n1. Sort the array, so three max numbers are in the end of the array, two negative numbers whose product will be max will be on the start of the array.\n2. return max of (nums[n-1]*nums[i-2]*nums[i-3], nums[0]*nums[1]*nums[n-1])\n\nApproach2:\nFind max1, max2, max3, min1 and min2 using a for loop\n```\n    public int maximumProduct(int[] nums) {\n        int min1, min2, max1, max2, max3;\n        min1 = min2 = Integer.MAX_VALUE;\n        max1 = max2 = max3 = Integer.MIN_VALUE;\n        for(int i = 0; i < nums.length; i++){\n            //Updating maximums\n            if(max1 < nums[i]){\n                max3 = max2;\n                max2 = max1;\n                max1 = nums[i];\n            }else if(max2 < nums[i]){\n                max3 = max2;\n                max2 = nums[i];\n            }else if(max3 < nums[i]){\n                max3 = nums[i];\n            }\n            \n            //Updating minimums\n            if(min1 > nums[i]){\n                min2 = min1;\n                min1 = nums[i];\n            }else if(min2 > nums[i]){\n                min2 = nums[i];\n            }\n            \n        }\n        \n        return Math.max(max1 * max2 * max3 , min1 * min2 * max1);\n    }\n\n```\nThis solution beats 99.72 % of java submissions. Kindly **UPVOTE**, if this helps.\n
['Java']