数据结构map的应用
public static String FirstAppearingOnce(String str){
Map<String, Integer> maps = new LinkedHashMap<String,Integer>();
for(int i =0; i<str.length();i++){
String key = String.valueOf(str.charAt(i));
if(!maps.containsKey(key)){
maps.put(key, 1);
}else{
int val = maps.get(key);
maps.put(key, val+1);
}
}
String result = null ;
for(Map.Entry i : maps.entrySet()){
if((int) i.getValue()==1){
result = (String) i.getKey();
break;
//System.out.println(i.getValue() +"=="+i.getKey());
}
}
return result;
}
```