Files
LeetCode-Go/leetcode/1624.Largest-Substring-Between-Two-Equal-Characters/1624. Largest Substring Between Two Equal Characters.go
YDZ 14d0942f5a 1. Add solution 1091、1614、1619、1624、1629、1636、1704
2. ctl strings.TrimSpace question.Title
2021-02-15 11:37:57 +08:00

17 lines
249 B
Go

package leetcode
import "strings"
func maxLengthBetweenEqualCharacters(s string) int {
res := -1
for k, v := range s {
tmp := strings.LastIndex(s, string(v))
if tmp > 0 {
if res < tmp-k-1 {
res = tmp - k - 1
}
}
}
return res
}