Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit af98ff0

Browse files
docs: update README_EN to lc problem: No.0058.Length of Last Word
1 parent 2792cf1 commit af98ff0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎solution/0000-0099/0058.Length of Last Word/README_EN.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ class Solution {
6868
}
6969
```
7070

71+
### **Rust**
72+
73+
```rust
74+
impl Solution {
75+
pub fn length_of_last_word(s: String) -> i32 {
76+
let s = s.trim_end();
77+
if s.len() == 0 {
78+
return 0;
79+
}
80+
for (i, c) in s.char_indices().rev() {
81+
if c == ' ' {
82+
return (s.len() - i - 1) as i32;
83+
}
84+
}
85+
s.len() as i32
86+
}
87+
}
88+
```
89+
7190
### **...**
7291

7392
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /