코딩테스트/프로그래머스 1단계
프로그래머스 1단계 - 자연수 뒤집어 배열로 만들기
SICDev
2021. 8. 19. 20:29
반응형
https://programmers.co.kr/learn/courses/30/lessons/12932
class Solution {
public int[] solution(long n) {
String num = Long.toString(n);
int[] answer = new int[num.length()];
int index = 0;
while(n != 0){
answer[index] = (int)(n%10);
n = n/10;
index++;
}
return answer;
}
}
반응형