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 static void main(String[] args) {
Scanner in = new Scanner(System.in);
long a = in.nextLong();
long b = in.nextLong();
long c = in.nextLong();
long d = in.nextLong();
long e = in.nextLong();
SortedSet p = new TreeSet();
p.add(b+c+d+e);
p.add(a+c+d+e);
p.add(a+b+d+e);
p.add(a+b+c+d);
System.out.println(p.first() +" " +p.last());
}
this code is not working 2,6,8,9,11
can anyone help me out?
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 →
public static void main(String[] args) { Scanner in = new Scanner(System.in); long a = in.nextLong(); long b = in.nextLong(); long c = in.nextLong(); long d = in.nextLong(); long e = in.nextLong(); SortedSet p = new TreeSet(); p.add(b+c+d+e); p.add(a+c+d+e); p.add(a+b+d+e); p.add(a+b+c+d); System.out.println(p.first() +" " +p.last()); }