題庫
00:00

8. Length of Last Word

簡單字串AmazonMicrosoft

Given a string s, return the length of its last word.

範例 1:

輸入: s = "Hello World"
輸出: 5

範例 2:

輸入: s = "   fly me   to   the moon  "
輸出: 4

限制條件:

  • 1 <= s.length <= 10^4
核心程式碼模式
● 已自動儲存第 1 行,第 1 欄