public class Solution {
/**
* @param str: s string
* @return: return an integer, denote the number of the palindromic substrings
*/
public int countPalindromicSubstrings(String str) {
// write your code here
if(str == null || str.length() == 0)
return 0;
int size = str.length(), res = 0;
for (int i = 0 ; i < size ;i++ ){
res += helper(str,i,i);
res += helper(str,i,i+1);
}
return res;
}
public int helper(String str, int i , int j){
int res = 0;
while(i >= 0 && j < str.length() && str.charAt(i)== str.charAt(j)){
i--;
j++;
res++;
}
return res;
}
}