본문 바로가기
기타/프로그래머스

[프로그래머스] Lv.0 배열 원소의 길이 - 자바(java)

by qkzkdo 2023. 8. 14.
728x90

문제 설명

문자열 배열 strlist가 매개변수로 주어집니다. strlist 각 원소의 길이를 담은 배열을 retrun하도록 solution 함수를 완성해주세요.

 

 

 

내가 작성한 답

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;
    }
}
728x90