Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 7 9 Max. score: 2 0 . 0 0 Tax payment Problem statement You are a manager in an office and keep a track
Question
Max. score:
Tax payment
Problem statement
You are a manager in an office and keep a track of all the N employees in the office. In an excel sheet, there are N rows and columns wherein the ith row st column denotes the id of the ith employee and nd column denotes the salary of the ith employee. The contents of the excel sheet are described by a D array A of size N
Task
You are given Q queries where each query is denoted by parameters lrx Each employee with a salary strictly greater than x needs to pay tax. You are asked to filter out the rows in the range l to r where employees will pay the tax. The answer to the query will be the number of rows left in the excel sheet after applying the given filter.
Note:
The queries are independent ie the changesfiltering made in the excel sheet in the previous queries will not be persisted.
The id numbers of all employees are distinct integers from to N
Example
Assumptions
N
A
queries
Approach
In the st query, only the th and th employees in the given range have salaries greater than So the number of rows left after applying the filter in the excel sheet is
In the nd query, all three employees in the given range have salaries greater than So the number of rows left after applying the filter in the excel sheet is
Function Description
Complete the filter function provided in the editor. This function takes the following parameters and returns the array of integers of size Q which represents the answer to the queries as described above in the problem statement.
N: represents the number of rows in the excel sheet.
A: represents a D array containing the id and the salary of the N employees.
queries: represents an array of size Q which denotes the query parameters lrx
Input Format
Note: This is the input format that you must use to provide custom input available above theCompile and Testbutton
The first line contains N thesize of the function parameter A
The next N lines contain twospaceseparated integers denoting the id and the salary of the N employees.
The second line contains the number of queries Qie the size of function parameter queries.
The next Q lines contain three spaceseparated integers
Output format
Print Q spaceseparated integers where each integer represents the answer to each query.
Constraints
Code snippets also called starter codeboilerplate code
This question has code snippets for C CPP Java, and Python.
Sample input
Sample output
Explanation
For the given sample input
Given
N
A
queries
Approach
In the st query, only the th and th employees in the given range have salaries greater than So the number of rows left after applying the filter in the excel sheet is
In the nd query, all three employees in the given range have salaries greater than So the number of rows left after applying the filter in the excel sheet is
The following test cases are the actual test cases of this question that may be used to evaluate your submission.
Sample input
Sample output
View more
Sample input
Sample output
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started