# 647. Palindromic Substrings

idea same as leetcode 5, start from middle point



O(n^2)

```java
class Solution {
    public int countSubstrings(String s) {
        int result = 0;
        for (int i = 0; i < s.length(); i++) {
            result = helper(s, i, i, result);
            result = helper(s, i, i+1, result);
        }
        return result;
    }
    private int helper(String s, int l, int r, int result) {
        while (l >= 0 && r < s.length() && s.charAt(l) == s.charAt(r)) {
            result++;
            l--;
            r++;
        }
        return result;
    }
}
```
