3378. Count Connected Components in LCM Graph
You are given an array of integers
numsof sizenand a positive integerthreshold.There is a graph consisting of
nnodes with theithnode having a value ofnums[i]. Two nodesiandjin the graph are connected via an undirected edge iflcm(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 ofaandb.
1 | class Solution { |