package leetcode;

/**
 * https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/
 */
public class Problem1491 {
    public double average(int[] salary) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1491 prob = new Problem1491();
        System.out.println(prob.average(new int[]{4000,3000,1000,2000})); // 2500.00000
        System.out.println(prob.average(new int[]{1000,2000,3000})); // 2000.00000
        System.out.println(prob.average(new int[]{6000,5000,4000,3000,2000,1000})); // 3500.00000
        System.out.println(prob.average(new int[]{8000,9000,2000,3000,6000,1000})); //  4750.00000
    }
}

@@ -191,499 +191,294 @@
     
-// TODO%0A        return 0
+int sum = 0;%0A        int min = Integer.MAX_VALUE
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1491 prob = new Problem1491();%0A        System.out.println(prob.average(new int%5B%5D%7B4000,3000,1000,2000%7D)); // 2500.00000%0A        System.out.println(prob.average(new int%5B%5D%7B1000,2000,3000%7D)); // 2000.00000%0A        System.out.println(prob.average(new int%5B%5D%7B6000,5000,4000,3000,2000,1000%7D)); // 3500.00000%0A        System.out.println(prob.average(new int%5B%5D%7B8000,9000,2000,3000,6000,1000%7D)); //  4750.00000
+int max = Integer.MIN_VALUE;%0A        for (int s : salary) %7B%0A            sum += s;%0A            min = Math.min(min, s);%0A            max = Math.max(max, s);%0A        %7D%0A        return (sum - min - max) / (double) (salary.length - 2);
 %0A   

Solve problem 1491