###### LeetCode 58. Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.

If the last word does not exist, return 0.

Note: A word is defined as a character sequence consists of non-space characters only.

For example,
Given s = "Hello World",
return 5.

int lengthOfLastWord(string s)
{
reverse(s.begin(),s.end());
int n = s.length();
int length = 0;
int i = 0;
while( i< n && s[i] == ' ')
i++;
while(i < n && s[i] != ' ')
{
i++;
length++;
}
return length;

}

#### LeetCode 58 — Length of Last Word（C++ Java Python）

2014-02-24 21:09:18

#### LeetCode OJ 系列之58 Length of Last Word --Python

2015-12-09 01:36:21

#### [LeetCode-58] Length of Last Word（最后一个单词长度）

2015-10-15 14:05:39

#### leetcode-java-58. Length of Last Word

2016-06-14 21:54:42

#### Length of Last Word -- LeetCode

2014-03-23 13:08:28

#### 58. Length of Last Word [easy] (Python)

2016-06-17 19:41:16

#### LeetCode58——Length of Last Word

2015-02-11 17:32:19

#### 【leetcode】58. Length of Last Word（Python & C++）

2017-09-06 20:54:42

#### leetcode笔记--Length of Last Word

2016-02-24 13:07:43

#### leetcode Length of Last Word java实现

2014-03-06 14:26:49

## 不良信息举报

LeetCode 58. Length of Last Word