Feature #4: Query Peak Users

Implementing the "Query Peak Users" feature for our "Cellular Operator AT&T" project.

Description

The cellular operator serves a rectangular region, represented by a 2D grid with one base station in each cell. Each base station is limited in the number of simultaneous users. During busy hours, some users get poor or no service. The company leadership wants to fix this problem by deploying multiple base stations, wherever necessary. Since this is a capital-intensive plan, we want to systematically deploy new base stations only where they are bound to help the most.

The operator has gathered the peak number of users connected to each base station. The executives want to query the obtained data and calculate the peak number of users that are connected to the base stations in a rectangular subset of the covered area. The executives may need to query the data multiple times. Therefore, we need to figure out an efficient way to execute the queries and return their results.

Note: The area to be queried is identified by the top-left and bottom-right cell coordinates.

The following illustration will help clarify to this problem:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.