We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticvoidminiMaxSum(List<Integer>arr){// find the total sum, smallest and largest elementslongsum=0;intmin=Integer.MAX_VALUE,max=Integer.MIN_VALUE;for(inta:arr){sum+=a;min=Math.min(min,a);max=Math.max(max,a);}// calculate the minimum and maximum sumslongminSum=sum-max;longmaxSum=sum-min;System.out.println(minSum+" "+maxSum);}
Cookie support is required to access HackerRank
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 →
java solution