Problem01 { public static List<SimpleEntry<Integer, Integer>> pairs(int[] numbers) { Arrays.sort(numbers); List<SimpleEntry<Integer, Integer>> pairs = new ArrayList<>(); for (int i = 0; i < numbers.length / 2; i++) { pairs.add(new SimpleEntry<>(numbers[i], numbers[(numbers.length - i) - 1])); } return pairs; }  static List<SimpleEntry<Integer, Integer>> pairs(int[] numbers);  }
@Test public void shouldCreatePairsByMinOfMaximumSumOfPairs() throws Exception { List<SimpleEntry<Integer, Integer>> pairs = Problem01.pairs(new int[]{1, 9, 3, 5}); assertThat(pairs, contains(new SimpleEntry<>(1, 9), new SimpleEntry<>(3, 5))); }