publicclassSolution { /** * @param str: s string * @return: return an integer, denote the number of the palindromic substrings */publicintcountPalindromicSubstrings(String str) {// write your code hereif(str ==null||str.length() ==0)return0;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; }publicinthelper(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; }}