LeetCode/kt/length-of-last-word.kt
2025-02-04 21:22:59 +01:00

3 lines
106 B
Kotlin

class Solution {
fun lengthOfLastWord(s: String): Int = s.trim().split(Regex("\\s+")).last().length
}