Practice Count Number of Rectangles Containing Each Point
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Count Number of Rectangles Containing Each Point
Problem Statement
You are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi. You are also given a 2D integer array points where points[j] = [xj, yj] is a point with coordinates (xj, yj). The ith rectangle has its bottom-left corner point at the coordinates (0, 0) and its top-right corner point at (li, hi). Return an integer array count of length points.length where count[j] is the number of rectangles that contain the jth point. The ith rectangle contains the jth point if 0 <= xj <= li and 0 <= yj <= hi. Note that points that lie on the edges of a rectangle are also considered to be contained by that rectangle.
Source: Count Number of Rectangles Containing Each Point on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
rectangles = [[1,2],[2,3],[2,5]], points = [[2,1],[1,4]]
[2,1]
# Example 2
rectangles = [[1,1],[2,2],[3,3]], points = [[1,3],[1,1]]
[1,3]
Constraints
Related LeetCode Problems
Practice more problems similar to Count Number of Rectangles Containing Each Point.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.