题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//反转字符串
StringBuilder sb = new StringBuilder(sc.nextLine()).reverse();
StringBuilder result = new StringBuilder();
String str = sb.toString();
//在map中作为key。确定数据是否存在
Map<Character, Integer> map = new HashMap<Character, Integer>();
for (int i = 0; i < str.length(); i++) {
if (map.get(str.charAt(i)) == null) {
map.put(str.charAt(i), 0);
result.append(str.charAt(i));
} else {
}
}
System.out.println(result);
}
}