你们能帮我解决您的建议吗 -提供以下代码:
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
// Complete the sherlockAndAnagrams function below.
static int sherlockAndAnagrams(String s) {
//Hashtable<Integer, String>sHash = new Hashtable<Integer, String>();
//Hashtable<Integer, String>sHash1 = new Hashtable<Integer, String>();
//Hashtable<Integer, String>sHash2 = new Hashtable<Integer, String>();
String[] sArray = new String[100];
int index = 0, count = 0;
for(int i=0; i<s.length(); i++){
for(int j=i+1; j<=s.length(); j++){
sArray[index] = s.substring(i,j);
index++;
System.out.println(s.substring(i,j));
System.out.println(Arrays.toString(sArray));
}
}
for(int i=0; i<sArray.length; i++){
for(int j=i; j<sArray.length; j++){
//char[] sArray1 = sArray[i].toCharArray();
//char[] sArray2 = sArray[j].toCharArray();
//System.out.println(sArray1);
//System.out.println(sArray2);
int index_str = 0;
Hashtable<Integer, String>sHash1 = new Hashtable<Integer, String>();
Hashtable<Integer, String>sHash2 = new Hashtable<Integer, String>();
sHash1.put(index_str, sArray[i]);
sHash2.put(index_str, sArray[j]); index_str++;
if(sHash1.equals(sHash2)){
count++;
}
}
}
//char sArray1[]=sHash.toString.toCharArray();
//System.out.println(sArray1);
/*for(int i=0; i<s.length()-1; i++){
for(int j=i+1; j<s.length(); j++){
if(i != j){
char sArray1[] = sHash[i].toString.toCharArray
}
}
}*/
//System.out.println(sHash);
return count;
}
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
int q = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
for (int qItr = 0; qItr < q; qItr++) {
String s = scanner.nextLine();
int result = sherlockAndAnagrams(s);
bufferedWriter.write(String.valueOf(result));
bufferedWriter.newLine();
}
bufferedWriter.close();
scanner.close();
}
}