[프로그래머스] [LV1] 자연수 뒤집어 배열로 만들기

업데이트:

📚 자연수 뒤집어 배열로 만들기

링크📎 : https://programmers.co.kr/learn/courses/30/lessons/12932

난이도 ⭐️

📖 문제

이미지

📝 내 풀이

import java.util.*;

class Solution {
    public int[] solution(long n) {
        ArrayList<Long> list = new ArrayList<Long>();
        
        while(n != 0){
            list.add(n % 10);
            n /= 10;
        }
        
        int[] answer = new int[list.size()];
        
        for(int i = 0; i < list.size(); i++)
            answer[i] = list.get(i).intValue();
        
        return answer;
    }
}

끝-!

댓글남기기