You are given a list of distinct positive integers nums.
Find the largest subset (let’s call it ans) such that for every pair (a, b) in
ans:
• a % b == 0 or b % a == 0
If more than one subset has the same maximum size, return any one of them.
Input: nums = [1, 2, 3]
Output: [1, 2] or [1, 3]
Explanation:
• In [1, 2], 2 % 1 = 0 • In [1, 3], 3 % 1 = 0
Input: nums = [1, 2, 4, 8]
Output: [1, 2, 4, 8]
Explanation:
Each number divides the next.
Accepted:
Submission: