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.
public class Main {
public static void main(String[] args) {
List arr = new ArrayList<>(Arrays.asList(256741038,623958417,467905213,714532089,938071625));
long totalSum = arr.stream().mapToLong(Integer::longValue).sum();
System.out.println(totalSum);
long max = 0;
long min = totalSum;
for (int value : arr){
long temp = totalSum - value;
if (temp > max) max = temp;
if (temp < min) min = temp;
}
System.out.print(min+" "+max);
}
}
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 →
import java.util.*;
public class Main { public static void main(String[] args) { List arr = new ArrayList<>(Arrays.asList(256741038,623958417,467905213,714532089,938071625));
} }