MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / rotateString

Function rotateString

rotate_string_796/solution.go:3–23  ·  view source on GitHub ↗
(A string, B string)

Source from the content-addressed store, hash-verified

1package rotate_string_796
2
3func rotateString(A string, B string) bool {
4 if len(A) != len(B) {
5 return false
6 }
7
8 if A == B {
9 return true
10 }
11
12 a := A
13 for i := 0; i < len(A); i++ {
14 if a == B {
15 return true
16 }
17
18 // rotate a by prepending end to front
19 a = a[len(A)-1:] + a[0:len(A)-1]
20 }
21
22 return false
23}

Callers 1

Test_rotateStringFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_rotateStringFunction · 0.68