Skip to content

Commit 09cb117

Browse files
Create 神秘的火柴人.md
1 parent 32bc4ce commit 09cb117

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
```
2+
3+
4+
class Solution {
5+
public:
6+
int lengthOfLastWord(string s) {
7+
int end = s.length()-1;
8+
while(s[end] == ' ')
9+
end--;
10+
11+
int ret = 0;
12+
while(end>=0 && s[end]!=' ')
13+
{
14+
end--;
15+
ret++;
16+
}
17+
18+
return ret;
19+
}
20+
};
21+
22+
23+
```

0 commit comments

Comments
 (0)