Skip to content

Commit b6057e9

Browse files
committed
feat: add rust solution to lcof problem: No.58 - ||
面试题 58 - II. 左旋转字符串
1 parent 7e42c9a commit b6057e9

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lcof/面试题58 - II. 左旋转字符串/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ func reverseLeftWords(s string, n int) string {
6565
}
6666
```
6767

68+
### **Rust**
69+
70+
```rust
71+
impl Solution {
72+
pub fn reverse_left_words(s: String, n: i32) -> String {
73+
let len = s.len() as i32;
74+
if n >= len {
75+
return s;
76+
}
77+
String::from(&s[n as usize..]) + &s[..n as usize]
78+
}
79+
}
80+
```
81+
6882
### **...**
6983

7084
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
impl Solution {
2+
pub fn reverse_left_words(s: String, n: i32) -> String {
3+
let len = s.len() as i32;
4+
if n >= len {
5+
return s;
6+
}
7+
String::from(&s[n as usize..]) + &s[..n as usize]
8+
}
9+
}

0 commit comments

Comments
 (0)