OYO Rooms | Tallest Buildings in a City
Anonymous User
900

N cities are located in xy plane and their co-ordinates (x_i, y_i) and heights (H_i) are provided.
R rectangles are drawn on the xy plane with bottom-left corner at (1, 1) and upper right corner at (a_i, b_i). Find the tallest building in each rectangle.

Constraints:

  • 1 <= N, R <= 10^5
  • 1 <= x_i, y_i, a_i, b_i <= 10^5
  • 1 <= H_i <= 10^9

Example:
Buildings' location and heights (x_i, y_i, h_i): [[2, 1, 5], [2, 2, 10], [2, 3, 11], [1, 3, 2], [3, 3, 9]]
Upper right coordinates of rectangles (a_i, b_i): [[2, 1], [2, 2], [3, 3]]
Output: [5, 10, 11]

Comments (2)