Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
count-connected-components-in-lcm-graph.json31 linesDownload Raw Back to root
1{2  "id": 3680,3  "name": "count-connected-components-in-lcm-graph",4  "difficulty": "Hard",5  "link": "https://leetcode.com/problems/count-connected-components-in-lcm-graph/",6  "date": "2024-11-23",7  "task_description": "You are given an array of integers `nums` of size `n` and a **positive** integer `threshold`. There is a graph consisting of `n` nodes with the `ith` node having a value of `nums[i]`. Two nodes `i` and `j` in the graph are connected via an **undirected** edge if `lcm(nums[i], nums[j]) <= threshold`. Return the number of **connected components** in this graph. A **connected component** is a subgraph of a graph in which there exists a path between any two vertices, and no vertex of the subgraph shares an edge with a vertex outside of the subgraph. The term `lcm(a, b)` denotes the **least common multiple** of `a` and `b`. **Example 1:** **Input:** nums = [2,4,8,3,9], threshold = 5 **Output:** 4 **Explanation:** The four connected components are `(2, 4)`, `(3)`, `(8)`, `(9)`. **Example 2:** **Input:** nums = [2,4,8,3,9,12], threshold = 10 **Output:** 2 **Explanation:** The two connected components are `(2, 3, 4, 8, 9)`, and `(12)`. **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i] <= 109` All elements of `nums` are unique. `1 <= threshold <= 2 * 105`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [2,4,8,3,9], threshold = 5",12      "output": "4 "13    },14    {15      "label": "Example 2",16      "input": "nums = [2,4,8,3,9,12], threshold = 10",17      "output": "2 "18    }19  ],20  "constraints": [21    "1 <= nums.length <= 105",22    "1 <= nums[i] <= 109",23    "All elements of nums are unique.",24    "1 <= threshold <= 2 * 105"25  ],26  "python_template": "class Solution(object):\n    def countComponents(self, nums, threshold):\n        \"\"\"\n        :type nums: List[int]\n        :type threshold: int\n        :rtype: int\n        \"\"\"\n        ",27  "java_template": "class Solution {\n    public int countComponents(int[] nums, int threshold) {\n        \n    }\n}",28  "metadata": {29    "func_name": "countComponents"30  }31}