选取字符创中最长字符,并统计出现次数 package test;import java.util.HashMap;import java.util.Scanner;public class Main {public static void main(String[] args) {@SuppressWarnings("resource")Scanner sc=new Scanner(System.in);
package test; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { @SuppressWarnings("resource") Scanner sc=new Scanner(System.in); String str=sc.nextLine(); long timestart=System.currentTimeMillis(); HashMapmap=map(str); if(map.values().isEmpty()){ System.out.println("null"); return; } for(String key:map.keySet()){ System.out.println(key+":"+map.get(key)); } long timeend=System.currentTimeMillis(); System.out.println((timeend-timestart)); } public static HashMap map(String str){ HashMap map=new HashMap (); for(int i=str.length()-1;i>0;i--){ String[]strs=new String[str.length()-i+1]; for(int j=0;j