package array;

import java.util.Arrays;

/**
 * Created by cuixiaodao on 10/15/017
 * for leetCode problem:
 * https://leetcode.com/problems/maximum-product-of-three-numbers/description/
 */

public class MaximumProductThree {
    /**
     * find maximum product of three numbers in nums
     *
     * @param nums, an array
     * @return the maximum product
     */
    public int maximumProduct(int[] nums) {
        Arrays.sort(nums);
        int last = nums.length - 1;
        return Math.max(nums[0] * nums[1] * nums[last],
                nums[last] * nums[last - 1] * nums[last - 2]);
    }
}
@@ -405,16 +405,74 @@
 nums) %7B%0A
+        // %E6%8E%92%E5%BA%8F%EF%BC%9B%E5%88%86%E7%B1%BB%E8%AE%A8%E8%AE%BA%EF%BC%9A all positive; all negative; have both%0A
         
@@ -652,8 +652,9 @@
 %0A    %7D%0A%7D
+%0A

add notes