Sort by

recency

|

1421 Discussions

|

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/HTbex2B-Yas

    int hurdleRace(int k, vector<int> height) {
        int mx = *max_element(height.begin(), height.end());
        return max(0, mx-k);
    }
    
  • + 0 comments
    function hurdleRace(k, height) {
        
        var highest_hurdle = -Infinity
        var difference  
        
        for (var i = 0; i < height.length ;i++)
        {
            
            if (highest_hurdle < height[i]){
                
                highest_hurdle = height[i]
                
            }
        }
        difference = highest_hurdle - k
        
        console.log(`Difference : ${difference}`)
        if (difference <= 0)
            return 0
        else
            return difference
            
    }
    
  • + 0 comments

    Solution From My Side

    def hurdleRace(k, height):
        if(k>= max(height)):
            return 0
        else:
            return abs(k - max(height))
    
  • + 0 comments

    JS, Javascriipt solution:-

    function hurdleRace(k, height) {
        const heighestHurdel = Math.max(...height);
        const doseNeeded = heighestHurdel - k;
        return doseNeeded > 0?doseNeeded:0;
    }
    
  • + 0 comments

    Kotlin solution:

    val tallestHeight = height.maxOrNull() ?: 0 val result = tallestHeight - k

    if (result < 0){
        return 0
    } else {
        return result
    }