# Question 11 : 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:

 Name Type Description n Integer The number of gifts and boxes a Integer array The size of gifts b Integer array The 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:

`#include <bits/stdc++.h>using namespace std; string Add(string s1,string s2){  int i=stoi(s1)+stoi(s2);  return to_string(i);} string rev(string s){   reverse(s.begin(),s.end());  return s;} bool Palindrome(string s1){  return s1==rev(s1);} int main(){  int n; cin>>n;  vector<int> p(n),h(n);  for(int i=0;i<n;i++) cin>>p[i];  for(int i=0;i<n;i++) cin>>h[i];  int c=0;  for(int i=0;i<n;i++)  for(int j=0;j<n;j++)  if(p[i]>h[j])  {    c++;h[j]-=1;break;  }  cout<<n-c;}`
```N=int(input())
people=[]
house=[]
#to read data of people and house arrays
for i in range(N): people.append(int(input()))
for i in range(N): house.append(int(input()))
count=0
for i in range(N):
for j in range(N):
if(people[i]<house[j]):
count+=1
house[j]=-1
break
print(N-count)```
```import java.util.*;
class Main {

public static void main(String args[]) {
Scanner sc = new Scanner(System.in);

int n;

n = sc.nextInt();
int p[] = new int[n];
int h[] = new int[n];

for (int i = 0; i < n; i++) {
p[i] = sc.nextInt();
}

for (int i = 0; i < n; i++) {
h[i] = sc.nextInt();
}
int c = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (p[i] > h[j]) {
c++;
h[j] -= 1;
break;
}
}
}

System.out.println(n - c);
}
}```