Simple 3 lines C++


  • 0
        int maximumProduct(vector<int>& nums) {
            sort(nums.begin(),nums.end());
            int n=nums.size()-1;
            return max(nums[n]*nums[n-1]*nums[n-2],nums[0]*nums[1]*nums[n]);
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.