MCPcopy Create free account
hub / github.com/MohamedMetwalli5/HackerRank-Solutions / MiniMaxSum

Class MiniMaxSum

ProblemSolving (General)/MiniMaxSum.java:9–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7import java.util.regex.*;
8
9public class MiniMaxSum {
10
11
12 public static void main(String[] args) {
13 Scanner input = new Scanner(System.in);
14 long[] arr = new long[5];
15 for(int i=0;i<5;i++){
16 arr[i] = input.nextLong();
17 }
18 for(int i=0;i<5;i++){
19 for(int j=1;j<(5-i);j++){
20 if(arr[j] < arr[j-1]){
21 long temp = arr[j];
22 arr[j] = arr[j-1];
23 arr[j-1] = temp;
24 }
25 }
26 }
27
28 System.out.print(arr[0] + arr[1] + arr[2] + arr[3]);
29 System.out.print(" ");
30 System.out.print(arr[4] + arr[1] + arr[2] + arr[3]);
31 }
32}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected