Tap here to switch tabs
Problem
Submissions

Problem: Largest Divisible Subset

Largest Divisible Subset asks you to choose the most elements from a unique positive integer array so every pair is divisible in one direction, then return that subset.

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

Largest Divisible Subset asks you to choose the most elements from a unique positive integer array so every pair is divisible in one direction, then return that subset.

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.