• + 0 comments

    Python 3 solution

    def hurdleRace(k, height):
        max_hurdle_height = max(height)  # Find the maximum height among the hurdles
        
        # Calculate the doses of potion needed to clear the hurdles
        doses_needed = max_hurdle_height - k
        
        # If doses_needed is less than or equal to zero, the character can already clear all hurdles
        if doses_needed <= 0:
            return 0
        else:
            return doses_needed