Question 11 : Santa and Gifts

Santa and gifts

Today we will discuss InfTQ Coding question that is Santta and Gifts that was asked in InfTQ Coding questionnfyTQ Advance Coding Section. We will see the Question description along with function description and the Test Cases along with there explanation.

You will find the solution of the problem which is asked for InfTQ Coding question in various programming language. 

Problem Statement

Christmas is here! Santa has already prepared the gifts for all children all around the world, however, he hasn’t picked them yet. Santa has N gifts, their sizes are given in an array, A, and he also has N boxes, their sizes are given in an array, B.

Santa packs the gifts in the boxes in the following way:

  1. He tries to put the gifts inside boxes from left to right.
  2. He goes through the boxes from left to right until he finds the first empty box that fits the current gift (the box’s size should be larger or equal to the current gift’s size), and Santa puts the current gift in that box.
  3. Santa moves to the next gift to the right.

You need to find the number of gifts which won’t be packed following Santa’s algorithms in packing the gifts.

Function Description:

  • Complete the santa function in the editor below. It has the following parameter(s):

Parameters:

NameTypeDescription
nInteger

The number of gifts and boxes

aInteger arrayThe size of gifts
bInteger arrayThe size of the boxes

Return:

The function must return an INTEGER denoting the number of gifts which won’t be packed.

 

Constraints:

  • 1 <= N <= 10^3
  • 1 <= A[i] <= 10^5
  • 1 <= B[i] <= 10^5

Input Format:

  • The first line contains an integer, N, denoting the number of elements in A.
  • Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing Ai.
  • Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing B

 

Output Format:

  • Sample Input 1
    2
    4
    5
    10
    4
  • Sample Output 1
    1

Explanation: