题解 | #字符集合#
字符集合
http://www.nowcoder.com/questionTerminal/784efd40ed8e465a84821c8f3970b7b5
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
while(scanner.hasNextLine()) {
String str = scanner.nextLine();
HashMap<Character, Integer> hashtable = new HashMap<Character,Integer>();
for(int i = 0;i<str.length();i++) {
if(!hashtable.containsKey(str.charAt(i))){
System.out.print(str.charAt(i));
hashtable.put(str.charAt(i),i);
}
}
System.out.println();
}
}
}
哈希表yyds!