stream 코딩테스트 풀이1 프로그래머스(JAVA) : 자릿수 더하기 Stream 사용한 풀이import java.util.*;public class Solution { public int solution(int n) { String number = String.valueOf(n); // int 인 경우, 각 자리 분리가 안되서 String 변환 후, Stream 처리 List answerList = Arrays.asList(number.split("")); int answer = answerList.stream() .map(Integer::parseInt) .reduce((x,y) -> x+y) .get(); return a.. 2022. 9. 11. 이전 1 다음