func maximumNumberOfStringPairs(words []string) int { n := len(words) set := make(map[string]bool, n) ans := 0 for _, word := range words { if set[revertStr(word)] { ans++ } set[word] = true } return ans }
func revertStr(str string) string { n := len(str) bytes := make([]byte, n) for i := 0; i < n; i++ { bytes[i] = str[n - i - 1] } return string(bytes) }