-
프로그래머스 - 자연수 뒤집어 배열로 만들기 [자바]Algorithms/- 프로그래머스 2022. 2. 2. 22:20
- 문제 링크 : 자연수 뒤집어 배열로 만들기
정답
class Solution { public int[] solution(long n) { int len = (int)Math.log10(n) + 1; int[] a = new int[len]; for(int i=0; i<len; i++){ a[i] = (int)(n % 10); n /= 10; } return a; } }
분석
- 숫자 다루기
- 숫자를 자리수 별로 다룰 수 있는지 묻는 문제
반응형