This website contains ALL LeetCode **Premium** problems for
**FREE!!**.

All leaked interview problems are collected from Internet.

All leaked interview problems are collected from Internet.

Given a set of **distinct** positive integers, find the largest subset such that every pair (S_{i}, S_{j}) of elements in this subset satisfies: S_{i} % S_{j} = 0 or S_{j} % S_{i} = 0.

If there are multiple solutions, return any subset is fine.

**Example 1:**

nums: [1,2,3] Result: [1,2] (of course, [1,3] will also be ok)

**Example 2:**

nums: [1,2,4,8] Result: [1,2,4,8]

**Credits:**

Special thanks to @Stomach_ache for adding this problem and creating all test cases.

b''