@@ -0,0 +1,1420 @@
+package java_problems.beginner;%0D%0A%0D%0Aimport java.util.Arrays;%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * You are given a sequence a1, a2, ..., aN. Find the smallest possible value of%0D%0A * ai + aj, where 1 %3C= i %3C j %3C= N.%0D%0A * %0D%0A * Input: %0D%0A * The first line of the input contains an integer T denoting the number of test%0D%0A * cases. The description of T test cases follows.%0D%0A * The first line of each description consists of a single integer N.%0D%0A * The second line of each description contains N space separated integers - a1,%0D%0A * a2, ..., aN respectively.%0D%0A * %0D%0A * Output: %0D%0A * For each test case, output a single line containing a single integer - the%0D%0A * smallest possible sum for the corresponding test case.%0D%0A * %0D%0A * Constraints: %0D%0A * T = 105, N = 2 : 13 points.%0D%0A * T = 105, 2 %3C= N %3C= 10 : 16 points.%0D%0A * T = 1000, 2 %3C= N %3C= 100 : 31 points.%0D%0A * T = 10, 2 %3C= N %3C= 105 : 40 points.%0D%0A * 1 %3C= ai %3C= 106%0D%0A * %0D%0A * Example %0D%0A * Input:%0D%0A * 1%0D%0A * 4%0D%0A * 5 1 3 4%0D%0A * %0D%0A * Output:%0D%0A * 4%0D%0A */%0D%0Apublic class SmallestPair %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09%0D%0A%09%09Scanner sc = new Scanner(System.in);%0D%0A%09%09int numCases = Integer.parseInt(sc.nextLine());%0D%0A%09%09for (int i = 0; i %3C numCases; i++) %7B%0D%0A%09%09%09int arrLength = sc.nextInt();%0D%0A%09%09%09int%5B%5D arr = new int%5BarrLength%5D;%0D%0A%09%09%09for (int j = 0; j %3C arr.length; j++) %7B%0D%0A%09%09%09%09arr%5Bj%5D = sc.nextInt();%0D%0A%09%09%09%7D%0D%0A%09%09%09Arrays.sort(arr);%0D%0A%09%09%09System.out.println(arr%5B0%5D + arr%5B1%5D);%0D%0A%09%09%7D%0D%0A%09%09sc.close();%0D%0A%09%7D%0D%0A%7D

Add SmallestPair