question archive Dan is playing a video game in which his character competes in a hurdle race

Dan is playing a video game in which his character competes in a hurdle race

Subject:Computer SciencePrice: Bought3

Dan is playing a video game in which his character competes in a hurdle race. Hurdles are of varying heights. and Dan has a maximum height he can jump. There is a magic potion he can take that pill increase his maximum height by 1 unit for each dose. Flow many doses of the potion must he take to be able to jump all of the hurdles. Given an array of hurdle heights height, and an initial maximum height Dan can jump, k determine the minimum number of doses Dan must take to be able to clear all the hurdles in the race. For example. if height [1, 2,3,3, 21 and Dan can jump 1 unit high naturally, he must lake a — 1 = 2 doses of potion lobe able to jump all of the hurdles. Function Description Complete the hurdleRace function in the editor below. It should return the minimum units of potion Dan needs to drink to jump all of the hurdles. hurdleRace has the following parameter(s): • k: an integer denoting the height Dan can jump naturally • height: an array of integers denoting the heights of each hurdle

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE