package leetcode;

/**
 * https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array/
 */
public class Problem1464 {
    public int maxProduct(int[] nums) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1464 prob = new Problem1464();
        System.out.println(prob.maxProduct(new int[]{3,4,5,2})); // 12
        System.out.println(prob.maxProduct(new int[]{1,5,4,5})); // 16
        System.out.println(prob.maxProduct(new int[]{3,7})); // 12
    }
}

@@ -177,38 +177,48 @@
     
-// TODO%0A        return
+int max1 = 0;%0A        int max2 =
  0;%0A    
 %7D%0A%0A 
@@ -217,310 +217,250 @@
     
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1464 prob = new Problem1464();%0A        System.out.println(prob.maxProduct(new int%5B%5D%7B3,4,5,2%7D)); // 12%0A        System.out.println(prob.maxProduct(new int%5B%5D%7B1,5,4,5%7D)); // 16%0A        System.out.println(prob.maxProduct(new int%5B%5D%7B3,7%7D)); // 12
+for (int num : nums) %7B%0A            if (num %3E max1) %7B%0A                max2 = max1;%0A                max1 = num;%0A            %7D else if (num %3E max2) %7B%0A                max2 = num;%0A            %7D%0A        %7D%0A        return (max1 - 1) * (max2 - 1);
 %0A   

Solve problem 1464