MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / rotate_string

Function rotate_string

796-rotate-string.rs:1–14  ·  view source on GitHub ↗
(s: String, goal: String)

Source from the content-addressed store, hash-verified

1pub fn rotate_string(s: String, goal: String) -> bool {
2 if s == goal {
3 return true;
4 }
5 let mut s_chars: Vec<char> = s.chars().collect();
6 let goal_chars: Vec<char> = goal.chars().collect();
7 for _i in 0..s.len() {
8 s_chars.rotate_left(1);
9 if s_chars == goal_chars {
10 return true;
11 }
12 }
13 return false;
14}
15
16fn main() {
17 let s = "abcde".to_string();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected