Leetcode 628 三个数的最大乘积

Leetcode 628 三个数的最大乘积

class Solution {
    public int maximumProduct(int[] nums) {
        Arrays.sort(nums);
        int len = nums.length;
        int a = nums[0] * nums[1] * nums[len - 1];
        int b = nums[len - 1] * nums[len - 2] * nums[len - 3];
        return a > b ? a : b;
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_43894577/article/details/88938165