0628 Maxinum Product of Three Numbers
问题概述
解题思路
class Solution
{
public:
int maximumProduct(std::vector<int>& nums)
{
std::sort(nums.begin(), nums.end());
int max1 = nums[0] * nums[1] * nums[nums.size() - 1];
int max2 = nums[nums.size() - 3] * nums[nums.size() - 2] * nums[nums.size() - 1];
return max1 > max2 ? max1 : max2;
}
};