✅ EASIEST || 💯 BEAST || 🧑‍💻 3 LINES CODE || ⭐ JAVA
\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal is to find the maximum product of three numbers in the array. There are 
```\n```\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**The goal is to find the maximum product of three numbers in the array. There are two potential scenarios:**\n1. The three largest numbers yield the maximum product.\n2. In cases where there are negative numbers, the product of the two smallest (negative) numbers and the largest positive number may yield the maximum product.\n\n```\n```\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. **Sort the Array**: Sorting the array allows us to easily identify the largest numbers as well as the smallest (potentially negative) numbers.\n2. **Calculate Two Possible Products**:\n    - The product of the three largest numbers.\n    - The product of the two smallest numbers (possibly negative) and the largest number.\n3. **Return the Maximum**: Return the larger of the two products.\n```\n```\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n**`O(n log n)`, where `n` is the length of the array, due to sorting.**\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n**O(1) if sorting is done in place.**\n```\n```\n# Code\n```java []\nclass Solution {\n    public int maximumProduct(int[] nums) {\n        Arrays.sort(nums);\n        \n        int n = nums.length;\n\n        return Math.max(nums[n - 1] * nums[n - 2] * nums[n - 3],\n                        nums[0] * nums[1] * nums[n - 1]);\n    }\n}\n```\n\n![upvote.png](https://assets.leetcode.com/users/images/65cee064-8156-46fb-b3b2-9c3f700da2de_1727436296.2506528.png)\n
['Array', 'Math', 'Sorting', 'Java']