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

Function reverseString

reverse_string_344/solution.go:3–14  ·  view source on GitHub ↗
(s []byte)

Source from the content-addressed store, hash-verified

1package reverse_string_344
2
3func reverseString(s []byte) {
4 for i := 0; i < len(s)-1; i++ {
5 j := len(s) - 1
6
7 for i < j {
8 hold := s[j]
9 s[j] = s[j-1]
10 s[j-1] = hold
11 j--
12 }
13 }
14}

Callers 1

Test_reverseStringFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_reverseStringFunction · 0.68