This is a verified interview question from Amazon. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Number of Retailers" covers key patterns like Other.
"In a newly planned city, where a city is located at each integral coordinate in a 2-dimensional plane, there are n Amazon retailers. The ith retailer residing in the city at the coordinate (xi, yi) can deliver to all the cities covered by the rectangle having the 4 corner points (0, 0), (xi, 0), (xi, yi), (0, yi). We say that a point (a, b) is covered by a rectangle if it lies inside the rectangle or on its boundaries. Note that no 2 retailers reside in the same city. Given q requests of the form (a, b), determine the number of retailers who can deliver to the city at the coordinate (a, b). ### Input - int retailers[n][2]: the retailers' coordinates - int requests[q][2]: the coordinates of cities to deliver to ### Output - int[q]: the ith element is the answer to the ith query ### Constraints - 1 ≤ n, q ≤ 75*10^4 - 1 ≤ retailers[i][0] ≤ 10^9 - 1 ≤ retailers[i][1] ≤ 100 - 0 ≤ requests[i][0] ≤ 10^9 - 0 ≤ requests[i][1] ≤ 100 - No two retailers share the same coordinates."
Join thousands of developers practicing for Amazon.