Ad
Code
Diff
  • import java.util.Arrays;
    import java.util.stream.Collectors;
    import java.util.List;
    public class Kumite {
      public static String highAndLow(String numbers) {
        List<Integer> list = Arrays.stream(numbers.split(" "))
                    .map(Integer::valueOf)
                    .sorted()
                    .collect(Collectors.toList());
        return list.get(list.size() - 1) + " " + list.get(0);
      }
    }
    
    • import java.util.*;
    • import java.util.Arrays;
    • import java.util.stream.Collectors;
    • import java.util.List;
    • public class Kumite {
    • public static String highAndLow(String numbers) {
    • Object maxValue = Arrays.stream(numbers.split(" "))
    • .filter(n -> Arrays.stream(numbers.split(" "))
    • .noneMatch(n2 -> Integer.parseInt(n2)>Integer.parseInt(n))).toArray()[0];
    • Object minValue = Arrays.stream(numbers.split(" "))
    • .filter(n -> Arrays.stream(numbers.split(" "))
    • .noneMatch(n2 -> Integer.parseInt(n2)<Integer.parseInt(n))).toArray()[0];
    • return maxValue +" "+minValue;
    • List<Integer> list = Arrays.stream(numbers.split(" "))
    • .map(Integer::valueOf)
    • .sorted()
    • .collect(Collectors.toList());
    • return list.get(list.size() - 1) + " " + list.get(0);
    • }
    • }