Ad

Ternary operator used. Unnessesary variable inlined

Code
Diff
  • import static java.util.stream.IntStream.of;
    
    interface HighLow {
        static int[] findLargestAndSmallest(int[] nums) {
            return (nums == null || nums.length == 0) ? null : new int[] {of(nums).summaryStatistics().getMin(), of(nums).summaryStatistics().getMax()};
        }
    }
    
    • import static java.util.stream.IntStream.of;
    • interface HighLow {
    • static int[] findLargestAndSmallest(int[] nums) {
    • if (nums == null || nums.length == 0) return null;
    • var iss = of(nums).summaryStatistics();
    • return new int[] {iss.getMin(), iss.getMax()};
    • return (nums == null || nums.length == 0) ? null : new int[] {of(nums).summaryStatistics().getMin(), of(nums).summaryStatistics().getMax()};
    • }
    • }