Sort by

recency

|

1448 Discussions

|

  • + 0 comments

    C++ Solution

    int hurdleRace(int k, vector height) { auto max_it = max_element(height.begin(), height.end()); return ((*max_it - k) < 0)?0 : *max_it - k; }

  • + 0 comments

    This is a great problem for thinking through logic step by step. It all comes down to checking the tallest hurdle and seeing if the character can already clear it. If not, just calculate how many extra boosts are needed. Pretty straightforward but a fun way to break down constraints. It kind of reminds me StreamVouch—sometimes you have all the tools you need, and other times you need that extra boost to make things work smoothly. Just like how some editing software gives you everything upfront while others require add-ons to get the job done efficiently.

  • + 0 comments

    This is a great problem for thinking through logic step by step. It all comes down to checking the tallest hurdle and seeing if the character, much like an extreme introvert navigating social situations, can already clear it. If not, just calculate how many extra boosts are needed. Pretty straightforward but a fun way to break down constraints.

  • + 0 comments

    import java.util.*;

    public class Solution {

    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();
    }
    

    }

  • + 0 comments

    int biggestHurdle = height.Max();

    return biggestHurdle > k ? biggestHurdle - k : 0;