Epython Lab
6.45K subscribers
660 photos
31 videos
104 files
1.22K links
Welcome to Epython Lab, where you can get resources to learn, one-on-one trainings on machine learning, business analytics, and Python, and solutions for business problems.

Buy ads: https://telega.io/c/epythonlab
Download Telegram
#ProblemSolving #Python3 #HurdleRace

A video player plays a game in which the character competes in a hurdle race. Hurdles are of varying heights, and the characters have a maximum height they can jump. There is a magic potion they can take that will increase their maximum jump height by unit for each dose. How many doses of the potion must the character take to be able to jump all of the hurdles. If the character can already clear all of the hurdles, return

.Example
height = [1, 2, 3, 3, 2]
k = 1

The character can jump 1 unit high initially and must take 3- 1 = 2 doses of potion to be able to jump all of the hurdles.

Function Description

Create the hurdleRace function.

hurdleRace has the following parameter(s):

int k: the height the character can jump naturally
int height[n]: the heights of each hurdle

Returns

int: the minimum number of doses required, always 0 or more

Sample Input 0

5 4
1 6 3 5 2

Sample Output

2
Post your solution @PythonETHBot
Also you can submit your solution at #Hackerank
“Python 3.9.0 is the newest feature release of the #python3 language” that comes with numerous features, and optimizations.