← All problemsSign in

952. Largest Component Size by Common Factor

LeetCodeArrayHash TableMathUnion-FindNumber TheoryOpen on judge ↗

You are given an integer array of unique positive integers nums. Consider the following graph: - There are nums.length nodes, labeled nums[0] to nums[nums.length - 1], - There is an undirected edge between nums[i] and nums[j] if nums[i] and nums[j] share a common factor greater than 1. Return the size of the largest connected component in the graph. Example 1: Input: nums = [4,6,15,35] Outp

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start