• + 1 comment

    Can anyone tell me why my code was wrong and why below code not able to pass all test case but few.

    Collections.sort(arr); Integer min=arr.get(0); Integer max=arr.get(arr.size()-1); Integer minSum=0; Integer maxSum=0; for (Integer i:arr) { if(i!=max) minSum+=i; if(i!=min) maxSum+=i; 34

    System.out.println(minSum+" "

    +maxSum );