values and targets. You may remove any number of elements from values.
The goal is for the smallest remaining element of values to divide every number in targets evenly. At least one element must remain in values.
Return the minimum number of removals, or -1 if the goal cannot be reached.values=[8, 6, 4, 12, 6], targets=[18, 30, 12] → 1
The smallest value 4 does not divide 18 or 30. After removing it, the smallest value is 6, which divides 18, 30 and 12. One removal.
values=[5, 10], targets=[7, 14] → -1
Neither 5 nor 10 divides 7, so it cannot be done.
values=[3, 1, 3], targets=[100] → 0
values=[8, 6, 4, 12, 6], targets=[18, 30, 12]
1
Run checks the first 3 tests in your browser. Submit checks all 160 tests on the server, hidden ones included.