Skip to content

Commit ee226e7

Browse files
committed
Update length-of-last-word.cpp
1 parent 4a5df2a commit ee226e7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/length-of-last-word.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class Solution {
55
public:
66
int lengthOfLastWord(string s) {
7-
const auto is_space = [](const char c) { return c == ' '; };
7+
const auto is_space = [](const char c) { return isspace(c); };
88
const auto it = find_if_not(s.rbegin(), s.rend(), is_space);
99
const auto jt = find_if(it, s.rend(), is_space);
1010
return distance(it, jt);

0 commit comments

Comments
 (0)