31 import java.io.*; 32 import java.util.*; 33 34 public class Solution { 35 36 public static void main(String[] args) { 37 Scanner input = new Scanner(System.in); int Q = input.nextInt(); 38 %3D 39...


Can you explain this code? It is "Permuting Two Arrays" Hackerrank question's solution.


31<br>import java.io.*;<br>32<br>import java.util.*;<br>33<br>34<br>public class Solution {<br>35<br>36<br>public static void main(String[] args) {<br>37<br>Scanner input = new Scanner(System.in);<br>int Q = input.nextInt();<br>38<br>%3D<br>39<br>//Store answer to each query<br>40<br>StringBuilder output<br>= new StringBuilder(

Extracted text: 31 import java.io.*; 32 import java.util.*; 33 34 public class Solution { 35 36 public static void main(String[] args) { 37 Scanner input = new Scanner(System.in); int Q = input.nextInt(); 38 %3D 39 //Store answer to each query 40 StringBuilder output = new StringBuilder(""); 41 42 queries: for (int q = 0; q < q;="" q++)="" 43="" 44="" {="" 45="" int="" n="input.nextInt();" int="" k="" -="" input.nextint();="" 46="" 47="" 48="" initialize="" input="" int[]="" a="new" int[n];="" 49="" 50="" int[]="" b="new" int[n];="" for="" (int="" i="0;" i="">< n;="" i++)="" 51="" 52="" a[i]="" input.nextint();="" for="" (int="" i="0;" i="">< n;="" i++)="" 53="" 54="" b[i]="input.nextInt();" 55="" 56="" arrays.sort(a);//sort="" ascending="" 57="" arrays.sort(b);//sort="" acending="" 58="" for="" (int="" i="0;" i="">< n;="" i++)="" 59="" 60="">
61<br>//Traverse A ascending and B descending<br>62<br>if(A[i]+B[B.length-1-i] < k) //Failed check<br>63<br>{<br>64<br>output.append(

Extracted text: 61 //Traverse A ascending and B descending 62 if(A[i]+B[B.length-1-i] < k)="" failed="" check="" 63="" {="" 64="" output.append("no\n");="" 65="" continue="" queries;="" 66="" }="" 67="" }="" 68="" 69="" permutation="" exist="" 70="" output.append("yes\n");="" 71="" 72="" 73="" print="" the="" answers="" to="" all="" queries="" 74="" system.out.println(output);="" 75="" }="" 76="">

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here