Question: I need this in C++ programming language. (Please Indent while writing the code! It makes it makes the code readable). Binary Search. A boy goes
I need this in C++ programming language. (Please Indent while writing the code! It makes it makes the code readable).
Binary Search.
A boy goes to buy video games from a shop. The shop contains N unique video games. The prices of the games are given in the form of an array A. The price of ith games is A[i]. Now the boy has q queries, in each query he wants to know the number of unique games that have a price less than the given amount M. Input:
The first line contains integer N total number of unique video games available in the shop.
The second line contains N space-separated integers (the price of the games).
The third line contains Q number of queries. Each of the next Q lines contain integer M. Output:
For each query output number of games having price less than M for that query. Sample Input:
5
1 4 10 5 6
4
2
3
5
11
Output for the sample input:
1
1
2
5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
