0952. Largest Component Size by Common Factor
https://leetcode.com/problems/largest-component-size-by-common-factor
Description
You are given an integer array of unique positive integers nums. Consider the following graph:
There are
nums.lengthnodes, labelednums[0]tonums[nums.length - 1],There is an undirected edge between
nums[i]andnums[j]ifnums[i]andnums[j]share a common factor greater than1.
Return the size of the largest connected component in the graph.
Example 1:

Example 2:

Example 3:

Constraints:
1 <= nums.length <= 2 * 1041 <= nums[i] <= 105All the values of
numsare unique.
ac
Last updated
Was this helpful?