628. Maximum Product of Three Numbers

PHOTO EMBED

Mon Apr 17 2023 19:19:13 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

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

https://leetcode.com/problems/maximum-product-of-three-numbers/