forked from doocs/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add rust solution to lcof problem: No.58 - ||
面试题 58 - II. 左旋转字符串
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
impl Solution { | ||
pub fn reverse_left_words(s: String, n: i32) -> String { | ||
let len = s.len() as i32; | ||
if n >= len { | ||
return s; | ||
} | ||
String::from(&s[n as usize..]) + &s[..n as usize] | ||
} | ||
} |