-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
https://www.inkdp.cn/leetcode3.html
返回总目录日刷leetcode–简单版 58. 最后一个单词的长度题目描述 解题思路 定义一个变量统计,从前往后遍历,遇到空格归零就可以了,注意处理最后几个个字符全为空格的情况 定义一个变量统计,从后往前便利,虽然时间复杂度同为 O(n),但是第二个明显快很多 示例代码1234567891011121314func lengthOfLastWord(s string) int {