s가 주어진다. 마지막 단어의 길이를 구해야 한다.1 <= s.length <= 10^4s에는 영어와 공백(' ')만 들어감class Solution {
public int lengthOfLastWord(String s) {
String[] words = s.trim().split(" "); // 앞뒤 공백 제거하고 공백으로 문자열 나눈다.
return words[words.length - 1].length(); // 마지막 단어의 길이 반환한다.
}
}