(s string)
| 1 | package palindromic_substrings_647 |
| 2 | |
| 3 | func 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 |