标签:
1 mport java.util.Collection; 2 import java.util.Collections; 3 import java.util.HashMap; 4 import java.util.Map; 5 import java.util.Scanner; 6 7 8 public class Main 9 { 10 11 public static void main(String[] args) 12 {//abcdabcddd 13 StringBuilder res = new StringBuilder(256); 14 Scanner sc =new Scanner(System.in); 15 String input = sc.nextLine(); 16 17 if(input.length() > 20) return ; 18 HashMap<Character, Integer> map = new HashMap<Character, Integer>(); 19 //count character times 20 char[] chs = input.toCharArray(); 21 for(char ch : chs) 22 { 23 if(!map.containsKey(ch)) 24 { 25 map.put(ch,1); 26 } 27 else 28 { 29 map.put(ch,map.get(ch)+1); 30 } 31 } 32 33 int min = Collections.min(map.values()); 34 //delete 35 for(char ch :chs) 36 { 37 if(min != map.get(ch)) 38 res.append(ch); 39 } 40 41 42 System.out.println(res.toString()); 43 44 } 45 46 }
标签:
原文地址:http://www.cnblogs.com/sweetculiji/p/4781301.html