Ad
Code
Diff
  • import java.util.Arrays;
    
    interface HighLow {
      static int[] findLargestAndSmallest(int[] nums) {
        if(nums == null || nums.length == 0) return null;
    
        int min = Arrays.stream(nums).min().orElseThrow();
        int max = Arrays.stream(nums).max().orElseThrow();
        return new int[]{min, max};
      }
    }
    
    • import java.util.Arrays;
    • interface HighLow {
    • static int[] findLargestAndSmallest(int[] nums) {
    • // Change min and max below to be the highest and lowest values
    • // in the nums array provided to the function
    • int min = -9;
    • int max = 9;
    • return new int[]{min, max};
    • }
    • }
    • static int[] findLargestAndSmallest(int[] nums) {
    • if(nums == null || nums.length == 0) return null;
    • int min = Arrays.stream(nums).min().orElseThrow();
    • int max = Arrays.stream(nums).max().orElseThrow();
    • return new int[]{min, max};
    • }
    • }