https://school.programmers.co.kr/learn/courses/30/lessons/68644
import java.util.*;
class Solution {
public int[] solution(int[] numbers) {
List<Integer> arr = new ArrayList<>();
for(int i =0; i<numbers.length; i++){
for(int j =i+1; j<numbers.length;j++){
if(!arr.contains(numbers[i]+numbers[j])){
arr.add(numbers[i]+numbers[j]);
}
}
}
int[] answer = new int[arr.size()];
for(int i =0; i< answer.length;i++){
answer[i]=arr.get(i);
}
Arrays.sort(answer);
return answer;
}
}
class Solution {
public int[] solution(int[] numbers) {
HashSet<Integer> set = new HashSet<Integer>();
for(int i = 0; i < numbers.length-1; i++) {
for(int j = i+1; j < numbers.length; j++) {
set.add(numbers[i] + numbers[j]);
}
}
ArrayList<Integer> list = new ArrayList<Integer>(set);
int[] answer = new int[list.size()];
for(int i = 0; i < answer.length; i++) {
answer[i] = list.get(i);
}
Arrays.sort(answer);
return answer;
}
}