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

Function countSubstrings

palindromic_substrings_647/solution.go:3–13  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

1package palindromic_substrings_647
2
3func countSubstrings(s string) int {
4 count := 0
5
6 // for each location which can be expanded into a palindrome
7 for i := 0; i < len(s); i++ {
8 count += expandCenter(s, i, i)
9 count += expandCenter(s, i, i+1)
10 }
11
12 return count
13}
14
15// expandCenter returns the number of palindromic strings
16// discovered by expanding around the passed left and right

Callers 1

Test_countSubstringsFunction · 0.85

Calls 1

expandCenterFunction · 0.85

Tested by 1

Test_countSubstringsFunction · 0.68