CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes304downloads
1{2    "id": 2333,3    "name": "count_number_of_rectangles_containing_each_point",4    "difficulty": "Medium",5    "link": "https://leetcode.com/problems/count-number-of-rectangles-containing-each-point/",6    "date": "1650153600000",7    "task_description": "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. **Example 1:** ``` **Input:** rectangles = [[1,2],[2,3],[2,5]], points = [[2,1],[1,4]] **Output:** [2,1] **Explanation:** The first rectangle contains no points. The second rectangle contains only the point (2, 1). The third rectangle contains the points (2, 1) and (1, 4). The number of rectangles that contain the point (2, 1) is 2. The number of rectangles that contain the point (1, 4) is 1. Therefore, we return [2, 1]. ``` **Example 2:** ``` **Input:** rectangles = [[1,1],[2,2],[3,3]], points = [[1,3],[1,1]] **Output:** [1,3] **Explanation: **The first rectangle contains only the point (1, 1). The second rectangle contains only the point (1, 1). The third rectangle contains the points (1, 3) and (1, 1). The number of rectangles that contain the point (1, 3) is 1. The number of rectangles that contain the point (1, 1) is 3. Therefore, we return [1, 3]. ``` **Constraints:** `1 <= rectangles.length, points.length <= 5 * 104` `rectangles[i].length == points[j].length == 2` `1 <= li, xj <= 109` `1 <= hi, yj <= 100` All the `rectangles` are **unique**. All the `points` are **unique**.",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "rectangles = [[1,2],[2,3],[2,5]], points = [[2,1],[1,4]]",12            "output": "[2,1] "13        },14        {15            "label": "Example 2",16            "input": "rectangles = [[1,1],[2,2],[3,3]], points = [[1,3],[1,1]]",17            "output": "[1,3] "18        }19    ],20    "private_test_cases": [],21    "haskell_template": "countRectangles :: [[Int]] -> [[Int]] -> [Int]\ncountRectangles rectangles points ",22    "ocaml_template": "let countRectangles (rectangles: int list list) (points: int list list) : int list =  ",23    "scala_template": "def countRectangles(rectangles: List[List[Int]],points: List[List[Int]]): List[Int] = { \n    \n}",24    "java_template": "public static List<Integer> countRectangles(List<List<Integer>> rectangles, List<List<Integer>> points) {\n\n}",25    "python_template": "class Solution(object):\n    def countRectangles(self, rectangles, points):\n        \"\"\"\n        :type rectangles: List[List[int]]\n        :type points: List[List[int]]\n        :rtype: List[int]\n        \"\"\"\n        "26}