https://school.programmers.co.kr/learn/courses/30/lessons/68644
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
import java.util.*;
class Solution {
public int[] solution(int[] numbers) {
List<Integer> list = new ArrayList<Integer>();
for(int i=0;i<numbers.length-1;i++){
for(int j=i+1;j<numbers.length;j++){
int result = numbers[i]+numbers[j];
if(!list.contains(result)){
list.add(result);
}
}
}
int length = list.size();
int[] answer=new int[length];
for(int i=0;i<length;i++){
answer[i]=list.get(i).intValue();
}
Arrays.sort(answer);
return answer;
}
}
'JAVA' 카테고리의 다른 글
[프로그래머스/자바] 추억 점수 (0) | 2024.01.16 |
---|---|
[프로그래머스/자바] [1차] 비밀지도 (0) | 2024.01.15 |
[프로그래머스/자바] 가장 가까운 같은 글자 (0) | 2024.01.13 |
[프로그래머스/자바] 최대공약수와 최소공배수 (1) | 2023.12.26 |
[프로그래머스/자바] 없는 숫자 더하기 (0) | 2023.09.24 |
댓글