My issue
not able to slolve
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
}
}
Learning course: Arrays using Java
Problem Link: Practice Problem in - CodeChef
@aparmit
plzz refer the following solution for better understanding of the logic and implementation
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
int N, max, min, sax;
int[] n;
for(int i= 0; i < t; i++){
N = scanner.nextInt();
n = new int[N];
for(int j = 0; j < N; j++){
n[j] = scanner.nextInt();
}
max = n[0];
for(int k = 0; k < N; k++){
if(n[k] > max){
max = n[k];
}
}
min = n[0];
for(int l = 0; l < N; l++){
if(n[l] < min){
min = n[l];
}
}
sax = min;
for(int m = 0; m < N; m++){
if(n[m] > sax && n[m] != max){
sax = n[m];
}
}
System.out.println(max + sax);
}
}
}