FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3809,3 "name": "properties-graph",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/properties-graph/",6 "date": "2025-03-16",7 "task_description": "You are given a 2D integer array `properties` having dimensions `n x m` and an integer `k`. Define a function `intersect(a, b)` that returns the **number of distinct integers** common to both arrays `a` and `b`. Construct an **undirected** graph where each index `i` corresponds to `properties[i]`. There is an edge between node `i` and node `j` if and only if `intersect(properties[i], properties[j]) >= k`, where `i` and `j` are in the range `[0, n - 1]` and `i != j`. Return the number of **connected components** in the resulting graph. **Example 1:** **Input:** properties = [[1,2],[1,1],[3,4],[4,5],[5,6],[7,7]], k = 1 **Output:** 3 **Explanation:** The graph formed has 3 connected components: **Example 2:** **Input:** properties = [[1,2,3],[2,3,4],[4,3,5]], k = 2 **Output:** 1 **Explanation:** The graph formed has 1 connected component: **Example 3:** **Input:** properties = [[1,1],[1,1]], k = 2 **Output:** 2 **Explanation:** `intersect(properties[0], properties[1]) = 1`, which is less than `k`. This means there is no edge between `properties[0]` and `properties[1]` in the graph. **Constraints:** `1 <= n == properties.length <= 100` `1 <= m == properties[i].length <= 100` `1 <= properties[i][j] <= 100` `1 <= k <= m`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "properties = [[1,2],[1,1],[3,4],[4,5],[5,6],[7,7]], k = 1",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "properties = [[1,2,3],[2,3,4],[4,3,5]], k = 2",17 "output": "1 "18 },19 {20 "label": "Example 3",21 "input": "properties = [[1,1],[1,1]], k = 2",22 "output": "2 "23 }24 ],25 "constraints": [26 "1 <= n == properties.length <= 100",27 "1 <= m == properties[i].length <= 100",28 "1 <= properties[i][j] <= 100",29 "1 <= k <= m"30 ],31 "python_template": "class Solution(object):\n def numberOfComponents(self, properties, k):\n \"\"\"\n :type properties: List[List[int]]\n :type k: int\n :rtype: int\n \"\"\"\n ",32 "java_template": "class Solution {\n public int numberOfComponents(int[][] properties, int k) {\n \n }\n}",33 "metadata": {34 "func_name": "numberOfComponents"35 }36}