Ad
Code
Diff
  • import java.util.*;
    interface HighLow {
      static int[] printLargestAndSmallest(int[] nums) {
        Arrays.sort(nums);
        return new int[] {nums[0], nums[nums.length-1]};
      }
    }
    • import java.util.*;
    • interface HighLow {
    • static int[] printLargestAndSmallest(int[] nums) {
    • int min = nums[0], max = nums[0];
    • for (int n : nums) {
    • if (n < min) min = n;
    • if (n > max) max = n;
    • }
    • return new int[] {min, max};
    • Arrays.sort(nums);
    • return new int[] {nums[0], nums[nums.length-1]};
    • }
    • }