From abf08b41ba40e330b307c6fdd412ede277467eb9 Mon Sep 17 00:00:00 2001 From: rl544 <111494264+rl544@users.noreply.github.com> Date: Sat, 17 Dec 2022 03:45:51 +0900 Subject: [PATCH] =?UTF-8?q?uploaded=20at=202022.=2012.=2017.=20=EC=98=A4?= =?UTF-8?q?=EC=A0=84=203:45:50?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- programmers/두 개 뽑아서 더하기/solution.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 programmers/두 개 뽑아서 더하기/solution.java diff --git a/programmers/두 개 뽑아서 더하기/solution.java b/programmers/두 개 뽑아서 더하기/solution.java new file mode 100644 index 0000000..a763c1f --- /dev/null +++ b/programmers/두 개 뽑아서 더하기/solution.java @@ -0,0 +1,14 @@ +// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/68644 + +import java.util.HashSet; +class Solution { + public int[] solution(int[] numbers) { + HashSet answer = new HashSet(); + for(int a = 0; a < numbers.length-1; a++){ + for(int b = a+1; b < numbers.length; b++){ + answer.add(numbers[a]+numbers[b]); + } + } + return answer.stream().sorted().mapToInt(x->x.intValue()).toArray(); + } +} \ No newline at end of file