题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
http://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Map<String,Integer> map = new HashMap();
int count =0;
while(sc.hasNext()){
String str = sc.nextLine();
String str2 = str;
count = str.length();
while(true){
int length = str.length();
String str1 = str.substring(0,1);
str=str.replace(str1,"");
map.put(str1,length-str.length());
if(count>length-str.length())
count=length-str.length();
if(str.length()==0)
break;
}
for(String s:map.keySet()){
int a = map.get(s);
if(a==count)
str2=str2.replace(s+"","");
}
System.out.println(str2);
}
}
}