Input: arr[ ] = {30, 31, 32, 33, 32, 32, 31, 30, 30, 32}, Q[ ] = {1, 3}
Output: 4 9
Explanation:
Frequency of 32 is 4, 30 is 3, 31 is 2 and 33 is 1.
For Q[0](=1), pick all 32. Hence count = 4.
For Q[1](=3), pick all 32, 30, and 31. Hence count = 4 + 3 + 2 = 9.
Input: arr[ ] = {22, 35, 22, 22, 35}, Q[ ] = {4, 5, 1}
Output: 5 5 3