Skip to content

Commit af98ff0

Browse files
committedSep 21, 2021
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

+19
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)