Sort by

recency

|

1432 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

    Perl:

    sub hurdleRace {
        my ($k, $height) = @_;
       
        return (max(@$height) < $k) ? 0 : max(@$height) - $k;
    }
    
  • + 0 comments

    Java one line solution

    public static int hurdleRace(int k, List<Integer> height) {
            return Collections.max(height) <= k ? 0 : Collections.max(height) - k;
        }
    
  • + 0 comments

    int hurdleRace(int k, vector height) { auto result = std::max_element(height.begin(), height.end()); if(k > *result) return 0; return *result - k; }

  • + 0 comments

    public static int hurdleRace(int k, List height) { int dens = 0; for( Integer x : height){ if(x>k && Math.abs(k-x) > dens){ dens = Math.abs(k-x); } } return dens; }