Problem of the day
You must return the maximum number of children whose greed can be satisfied.
Input:
GREED = [3, 5, 6, 4], SIZE = [1, 4, 5], N = 4, M = 3
Output:
2
Explanation: We can assign the second cookie to the fourth child and the third to the second.
Hence we return 2.
The first line of the input will contain two integers, ‘N’ and ‘M’, denoting the length of the array ‘GREED’ and ‘SIZE’.
The second line contains ‘N’ space-separated integers of the array ‘GREED’.
The third line contains ‘M’ space-separated integers of the array ‘SIZE’.
Output Format:-
The only line consists of a single integer denoting the maximum number of children whose greed can be satisfied.
Note:-
You don’t need to print anything. Just implement the given function.
3 4
1 2 3
1 2 3 4
3
Input:
GREED = [1, 2, 3], SIZE = [1, 2, 3, 4], N = 3, M = 4
Output:
3
Explanation: We can assign the first cookie to the first child, the second cookie to the second child, and the third cookie to the third child.
Hence we return 2.
5 5
4 5 6 7 8
2 3 4 5 6
3
1 <= N, M <= 10^5
1 <= GREED[i], SIZE[j] <= 10^9
Time Limit: 1 sec