Tap here to switch tabs
Problem
Submissions

Problem: Largest Divisible Subset

med
30 min
Try to solve the Largest Divisible Subset problem.

Statement

Given an integer array nums of unique positive integers, find the largest subset such that every pair of elements (a, b) in this subset satisfies either a % b == 0 or b % a == 0.

If multiple valid subsets have the maximum size, return any one of them.

Note: The elements in the subset may be returned in any order.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤2imes109\leq 2 imes 10^9

  • All integers in nums are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Largest Divisible Subset

med
30 min
Try to solve the Largest Divisible Subset problem.

Statement

Given an integer array nums of unique positive integers, find the largest subset such that every pair of elements (a, b) in this subset satisfies either a % b == 0 or b % a == 0.

If multiple valid subsets have the maximum size, return any one of them.

Note: The elements in the subset may be returned in any order.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤2imes109\leq 2 imes 10^9

  • All integers in nums are unique.