Fitting The Array
Easy Accuracy: 23.53% Submissions: 17 Points: 2

Adobe is playing an array game. He is weak in the concepts of arrays. Adobe is given two arrays a[ ] and b[ ] of the same size. The array a[ ] will be said to fit in array b[ ] if by arranging the elements of both array, there exists a solution such that i_th element of a[ ] is less than or equal to an i_th element of b[ ]. Help Adobe find if the given arrays are fit or not.

Example 1:

​Input : A[] = {7, 5, 3, 2} and 
        B[] = {5, 4, 8, 7}
Output : YES
Transform A = {2, 3, 5, 7} and 
B = {4, 5, 7, 8}. then both array will 
fit in between.

​Example 2:

Input : A[] = {1, 2, 3} and B[] = {1, 2, 3} 
Output :  YES 


Your Task:
This is a function problem. The input is already taken care of by the driver code. You only need to complete the function isFit() that takes an array (a), another array (b), sizeOfArray (n), and return true if array a[ ] fit in array b[ ] otherwise print false. The driver code takes care of the printing.

Expected Time Complexity: O(N*LOG(N)).
Expected Auxiliary Space: O(1).

1 ≤ N ≤ 105
0 ≤ a[i], b[i] ≤ 105

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Fitting The Array

Output Window