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.
public static int hurdleRace(int k, List<Integer> height) {
int maxHurdle = Collections.max(height);
return Math.max(0, maxHurdle - k);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt(); // number of hurdles
int k = scanner.nextInt(); // max jump height
List<Integer> height = new ArrayList<>();
for (int i = 0; i < n; i++) {
height.add(scanner.nextInt());
}
int result = hurdleRace(k, height);
System.out.println(result);
scanner.close();
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Hurdle Race
You are viewing a single comment's thread. Return to all comments →
import java.util.*;
public class Solution {
}