Largest Divisible Subset
You are given a set of numbers
nums consisting of distinct numbers. Find the size of the
largest subset that satisfies the following condition: for each two number pairings in the
set, one number is divisible by the other.
nums: a list integers representing the set.
An integer representing the size of the largest subset that satisfy the condition.
1nums = [1, 2, 3]
[1, 2] or
[1, 3] satisfy the condition, because both
3 are both
1. Either way, the largest set has a size of
1nums = [1, 2, 4, 8]
In this set, for each pair of numbers, at least one is divisible by the other because
they are all powers of
2. As such, the max subset has a size of
4, the size of
the original set.
1 <= len(nums) <= 1000
1 <= nums[i] <= 10^9
- Each number in