You are viewing a single comment's thread. Return to all comments →
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 );
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
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 );