Skip to content

Commit ccf024b

Browse files
authored
Create Sagittarius.md
1 parent 6d88e10 commit ccf024b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

2018.12.3-leetcode58/Sagittarius.md

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

0 commit comments

Comments
 (0)