🔍Very Easy, Simple and Short Solution🚀
Intuition\nThe key intuition is that the maximum product can arise from:\n\nThree largest positive numbers.\nTwo smallest negative numbers and the largest posit
# Intuition\nThe key intuition is that the maximum product can arise from:\n\nThree largest positive numbers.\nTwo smallest negative numbers and the largest positive number.\n\n# Approach\nSort the array: Sort the array in ascending order.\n\nCalculate products:\n\nCalculate the product of the three largest elements.\nCalculate the product of the two smallest elements and the largest element.\nReturn the maximum: Return the larger of these two products.\n\n# Complexity\n- Time complexity:\nThe time complexity is dominated by the sorting operation, which is O(n log n) using efficient sorting algorithms like Merge Sort or Quick Sort.\n\n- Space complexity:\nThe space complexity is O(1) if the sorting algorithm used is in-place (like Heap Sort).\nThe space complexity is O(n) if the sorting algorithm uses additional memory (like Merge Sort).\n\n# Code\n```java []\nclass Solution {\n    public int maximumProduct(int[] nums) {\n        Arrays.sort(nums);\n        int n=nums.length;\n        int a=nums[n-1]*nums[n-2]*nums[n-3];\n        int b=nums[0]*nums[1]*nums[n-1];\n        return Math.max(a,b);\n    }\n}\n```
['Java']