Question: ski slope: 0 . . . N snow making machine at the ski slope. each machine is tuple of ( index , range ) indicating

ski slope: 0...N
snow making machine at the ski slope. each machine is tuple of (index, range) indicating machine is on the slope at index and is capable of covering the slope with snow up to range indices away. Find smalled number of snow machines that need to be turned on to cover entire slope. if not possible return -1
Example:
N=2, machines : [(0,1),(1,1),(2,1)] # output 1-> need to turn on middle machine
N=3, machines =[(0,2)] # output -1
N=5, machines=[(0,2),(1,1),(3,1),(4,1)] #output: 2-> either machine at 0r index 1 and machine at 4th index

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!