I'm trying to figure out the algorithm to implement a method and I would need some advice in the regard. I have given an array and range,
A = [1, 15, 30, 40, 50]
range = 10
I need to figure out the minimum number of points that would cover all the numbers of the given array.
Cover means that distance you can reach both left and right with the provided range. For example, if I have a point at 23 and range of 5, then I can reach 18-23 left side and 23-28 right side. The points can cover both the left and the right sides of the given range.
In the provided array the result is 3. We would need one point at 1, another at 15, and 3rd one at 40. I explain it below,
i. The point at 1 will cover till 10 (1-10)
ii. The point at 15 will cover itself (15)
iii. The point at 40 will cover left till the 30 and at the right till the 50 (30-40-50)
Please, provide a good reason before you attempt to downvote. Thank you.