[java] 프로그래머스 - 배열 원소의 길이

0

[문제링크 - 프로그래머스 - 배열 원소의 길이] https://school.programmers.co.kr/learn/courses/30/lessons/120854

class Solution {
    public int[] solution(String[] strlist) {
        int[] answer = new int[strlist.length];
        for(int i=0; i<strlist.length; i++){
            answer[i] = strlist[i].length();
        }
        return answer;
    }
}

class Solution1 {
    public int[] solution(String[] strlist) {
        return Arrays.stream(strlist).mapToInt(String::length).toArray();
    }
}
profile
초심 잃지 않기

0개의 댓글