#3444

Minimum Increments for Target Multiples in an Array

hard · 27.4% accepted · 87 likes · top 5%

array · math · dynamic programming · bit manipulation · number theory · bitmask

Description

You are given two arrays, nums and target.

In a single operation, you may increment any element of nums by 1.

Return the minimum number of operations required so that each element in target has at least one multiple in nums.

Solution