Count the elements
Easy Accuracy: 60.23% Submissions: 684 Points: 2

Given two arrays a and b. Given q queries each having a positive integer i denoting an index of the array a. For each query, your task is to find all the elements less than or equal to qi in the array b.

Example 1:

Input:
N=6
a[] = {1, 2, 3, 4, 7, 9}
b[] = {0, 1, 2, 1, 1, 4}
Query 1 -> 5
Query 2 -> 4
Output : 6
6
Explanation: For 1st query, the given index is 5,
A[5] is 9 and in B all the elements
are smaller than 9.
For 2nd query, the given index is 4,
A[4] is 7 and in B all the elements
are smaller than 7.   

Since, this is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function find() that takes array a , array b, array q as parameters and returns an array that contains the answer to the corresponding queries.

Expected Time Complexity: O(n).
Expected Auxiliary Space: O(n).

Constraints:
1 ≤ n ≤ 107

We are replacing the old Disqus forum with the new Discussions section given below.

### Editorial

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

#### My Submissions:

Count the elements