Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make Array Divisible

med
30 min
Try to solve the Minimum Deletions to Make Array Divisible problem.

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

med
30 min
Try to solve the Minimum Deletions to Make Array Divisible problem.

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