import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param str string字符串
* @return int整型
*/
public int Substrings (String str) {
int num = 0;
// HashMap<String,Boolean> map =new HashMap<>();
System.out.print("str"+str);
// write code here
for(int i = 0;i<str.length();i++){
String indexStr = str.charAt(i)+"";
for(int j = i;j<str.length();j++){
String temp ="";
if(i==j){
temp = indexStr;
}else{
temp = indexStr + str.charAt(j)+"";
}
boolean flag = isValid (temp);
indexStr = temp;
//Boolean flag2 = map.get(temp);
if(flag ){
num++;
}
}
}
return num;
}
public boolean isValid (String str) {
int length = str.length();
for(int i = 0;i<=length/2;i++){
if(str.charAt(i)!=str.charAt(length- 1- i)) return false;
}
return true;
}
}