728x90
문제 설명
문자열 배열 strlist가 매개변수로 주어집니다. strlist 각 원소의 길이를 담은 배열을 return하도록 solution 함수를 완성해주세요.
제한사항
- 1 ≤ strlist 원소의 길이 ≤ 100
- strlist는 알파벳 소문자, 대문자, 특수문자로 구성되어 있습니다.
입출력 예
strlist | result |
["We", "are", "the", "world!"] | [2, 3, 3, 6] |
["I", "Love", "Programmers."] | [1, 4, 12] |
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
'Programmers > Level. 0' 카테고리의 다른 글
[프로그래머스, Java] 배열 자르기 (0) | 2022.12.26 |
---|---|
[프로그래머스, Java] 특정 문자 제거하기 (0) | 2022.12.26 |
[프로그래머스, Java] 점의 위치 구하기 (0) | 2022.12.25 |
[프로그래머스, Java] 문자열 뒤집기 (0) | 2022.12.25 |
[프로그래머스, Java] 편지 (0) | 2022.12.25 |