[입문] 배열 원소의 길이 (JAVA)

ByeolGyu·2024년 4월 1일
post-thumbnail

<문제>

<작성 코드>

class Solution {
    public int[] solution(String[] strlist) {
    	//strlist와 길이가 같은 배열 생성 
        int[] answer = new int [strlist.length];
        
        //각 문자열의 길이를 answer 배열에 저장
        for(int i=0; i<strlist.length; i++){
            answer[i] = strlist[i].length();
        }       
        return answer;
    }
}

profile
ByeolGyu

0개의 댓글