interface HighLow { static int[] printLargestAndSmallest(int[] nums) { int min = nums[0], max = nums[0]; for (int n : nums) { min = min <= n ? min : n; max = max >= n ? max : n; } return new int[] {min, max}; } }
- 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;- min = min <= n ? min : n;
- max = max >= n ? max : n;
- }
- return new int[] {min, max};
- }
- }