문제설명

솔루션
import java.util.*;
class Solution {
public int[] solution(int n) {
HashSet<Integer> set = new HashSet<>(); //중복되지 않기 때문
for(int i = 2; i <= n; i++){
while(n % i == 0){
set.add(i);
n /= i;
}
}
if(n != 1){
set.add(n);
}
return set.stream().mapToInt(Integer::intValue).sorted().toArray();
}
}'java' 카테고리의 다른 글
| [프로그래머스 - 자바] 잘라서 배열로 저장하기 (0) | 2023.09.01 |
|---|---|
| [프로그래머스 - 자바] 공던지기 (0) | 2023.09.01 |
| [프로그래머스 - 자바] 7의 개수 (0) | 2023.09.01 |
| [프로그래머스 - 자바] 컨트롤제트 (0) | 2023.09.01 |
| [프로그래머스 - 자바] 이진수 더하기 (0) | 2023.09.01 |