We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The Hurdle Race
The Hurdle Race
Sort by
recency
|
1432 Discussions
|
Please Login in order to post a comment
Here is my c++ solution, you can watch the explanation here : https://youtu.be/HTbex2B-Yas
Perl:
Java one line solution
int hurdleRace(int k, vector height) { auto result = std::max_element(height.begin(), height.end()); if(k > *result) return 0; return *result - k; }
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; }