题解 | #提取不重复的整数#
提取不重复的整数
http://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
使用boolean数组储存状态更快
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt();
boolean[] used = new boolean[10];
StringBuilder sb = new StringBuilder();
while (num != 0) {
int a = num % 10;
if (used[a] == false) {
sb.append(a);
used[a] = true;
}
num /= 10;
}
System.out.println(sb.toString());
}
}