expandCenter returns the number of palindromic strings discovered by expanding around the passed left and right index in the passed string s.
(s string, left, right int)
| 16 | // discovered by expanding around the passed left and right |
| 17 | // index in the passed string s. |
| 18 | func expandCenter(s string, left, right int) int { |
| 19 | cnt := 0 |
| 20 | for left > -1 && right < len(s) && s[left] == s[right] { |
| 21 | left-- |
| 22 | right++ |
| 23 | cnt++ |
| 24 | } |
| 25 | |
| 26 | return cnt |
| 27 | } |