题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
int num = sc.nextInt();
HashSet<Integer> hs = new HashSet<>();
String result = "";
while(num > 0) {
int res = num % 10;
num /= 10;
if(hs.add(res)) {
result = result + res;
}
}
System.out.print(result);
}
}
}
查看8道真题和解析