Easy approach in C++
Intuition\nTo find maximum at first i thught just to find the max by sorting . ANd i did the same . But we have to check for an extra condition for -ve ones\n D
# Intuition\nTo find maximum at first i thught just to find the max by sorting . ANd i did the same . But we have to check for an extra condition for -ve ones\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nFirst sort the vector which will make it easy to iterate directly on indices.\nthen checking where the product of last three is maximum or product of first 2 and last 1 is maximum (In case of negatice number the smallest one will be at starting and after multiplying -ve we will get +ve)\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumProduct(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        int product;\n        int j=nums.size()-1;\n\n        return max(nums[j]*nums[j-1]*nums[j-2] , nums[0]*nums[1]*nums[j]);\n        \n    }\n};\n```
['C++']