Skip to main content

Posts

Showing posts from January, 2021

Placement Problem 1

 Don't jump directly to the solution.  Read the problem carefully and try to solve it on your own. Solution : Java Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 import java.util.Scanner; public class PlacementProblem1 { public static void main (String[] args) { Scanner sc = new Scanner(System. in ); int t = sc. nextInt (); while (t--> 0 ) { int size = sc. nextInt (); int target = sc. nextInt (); int arr[] = new int [size]; for ( int i= 0 ; i<arr. length ; i++) arr[i] = sc. nextInt (); for ( int i= 0 ; i<arr. length ; i++) { boolean flag = false ; for ( int j=i+ 1 ; j<arr. length ; j++) { if (arr[i]+arr[j]==target) { System. out . println (i+ " " +j);