정수 n이 매개변수로 주어질 때
n의 각 자리 숫자의 합
을 return하도록 solution 함수를 완성해주세요
class Solution {
public int solution(int n) {
int answer = 0;
String[] temp = String.valueOf(n).split("");
for(int i = 0; i < temp.length; i++) {
answer += Integer.parseInt(temp[i]);
}
return answer;
}
}