Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make Array Divisible

Minimum Deletions to Make Array Divisible asks you to remove as few elements as possible so the smallest value left in nums divides every value in numsDivide, or return -1 if impossible.

Statement

Given two positive integer arrays nums and numsDivide, you can delete any number of elements from nums.

Return the minimum number of deletions needed such that the smallest element in nums divides all elements of numsDivide. If no such element exists after any number of deletions, return −1-1.

Note: An integer xx divides yy if y(modx)=0y \pmod x = 0.

Constraints:

  • 1≤1 \leq nums.length, numsDivide.length ≤105\leq 10^5

  • 1≤1 \leq nums[i], numsDivide[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make Array Divisible

Minimum Deletions to Make Array Divisible asks you to remove as few elements as possible so the smallest value left in nums divides every value in numsDivide, or return -1 if impossible.

Statement

Given two positive integer arrays nums and numsDivide, you can delete any number of elements from nums.

Return the minimum number of deletions needed such that the smallest element in nums divides all elements of numsDivide. If no such element exists after any number of deletions, return −1-1.

Note: An integer xx divides yy if y(modx)=0y \pmod x = 0.

Constraints:

  • 1≤1 \leq nums.length, numsDivide.length ≤105\leq 10^5

  • 1≤1 \leq nums[i], numsDivide[i] ≤109\leq 10^9