Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@codeantik | 448 |

@SherlockHolmes3 | 447 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

Complete Leaderboard |

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
**Explanation:**
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).

**Constraints:**

1 ≤ N ≤ 10^{5}

0 ≤ a[i], b[i] ≤ 10^{5}

Login 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?

Yes
Fitting The Array

...