Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ or Java make sure it runs. Thanks Profit sort You are given the profits of a company for N days and Q queries are

C++ or Java

make sure it runs. Thanks

Profit sort

You are given the profits of a company for N days and Q queries are prepared on this file. Each query contains two integers, Land R.

Write a program to calculate the number of days on which the profit falls between the range L and R (both inclusive).

Input format

First line: N

Second line: N space-separated integers (denoting the profit for each day)

Third line: Q

First line in each query: L and R

Output format

Print the number of days on which the profit is greater than or equal to L and less than or equal to R.

Constraints

1N105 1Profitforeachday107 1Q105 1L,R105

Sample Input

5 23 13 10 2 33 5 7 11 10 30 1 10 2 40 5 6

Sample Output

1 3 2 5 0

Explanation

For First Query, we have profits of value 10 in the given range. For Second Query, we have profits of value 10,13,23 in the given range.

For Third Query, we have profits of value 2,10 in the given range. For Fourth Query, we have all profits in the given range. For Fifth Query, we have no profits in the given range.

Note: Your code should be able to convert the sample input into the sample output. However, this is not enough to pass the challenge, because the code will be run on multiple test cases. Therefore, your code must solve this problem statement.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

What are the role of supervisors ?

Answered: 1 week ago

Question

LO4 Provide an overview of four challenges facing HR today.

Answered: 1 week ago