➜ ~

Playing Hacks and Stuffs!


Project maintained by h4ckyou Hosted on GitHub Pages — Theme by mattgraham

Find the Smallest Divisor Given a Threshold

image

We are given an array nums with an integer threshold. Our goal is to find a positive integer divisor which would divide all the elements in the array by it. If the sum of all the result is less than or equal to the threshold we should return the smallest divisor value

One thing we should note there is that the value of divisor does not nessary means it has to belong to the arrary nums as it can be greater than the maximum value in the array

Here’s the first approach I took in solving this:

Solve Script: link image