728x90
class Solution:
def lengthOfLastWord(self, s: str) -> int:
s = s.rstrip().split(" ")
return len(s[-1])
https://leetcode.com/problems/length-of-last-word/description
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 938. Range Sum of BST (0) | 2024.04.05 |
---|---|
[Leetcode] 205. Isomorphic Strings (0) | 2024.04.02 |
[Leetcode] 3099. Harshad Number (0) | 2024.03.31 |
[Leetcode] 2962. Count Subarrays Where Max Element Appears at Least K Times (0) | 2024.03.29 |
[Leetcode] 41. First Missing Positive (1) | 2024.03.26 |