x/masx200_leetcode_test/reverse-prefix-of-word/index.go
1234567891011121314package indeximport "strings"import "github.com/webx-top/com"func reversePrefix(word string, ch byte) string { index := strings.IndexByte(word, ch) if index < 0 { return word } return com.Reverse(word[0:index+1]) + string(word[index+1:])}