알고리즘
배열 원소의 길이
Baro_forest
2023. 3. 14. 23:43
class Solution {
public int[] solution(String[] strlist) {
int[] answer = new int [strlist.length];
int length = strlist.length;
for(int i= 0; i < strlist.length; i++) {
answer[i] = strlist[i].length();
}
return answer;
}
}
length를 이용해 answer[i] 번째의의 단어를 strlist[i]의 길이값으로 변환.