forked from Doragd/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
-
输入一个 int 型整数,按照从右向左的阅读顺序,返回一个不含重复数字的新的整数。
保证输入的整数最后一位不是 0 。 -
数据范围:
-
递归遍历+问题分解+分类讨论
- 采用Linkedhashset
- 倒叙
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int input = in.nextInt();
Set<Integer> linkedHashSet = new LinkedHashSet<>(Collections.singletonList(
input));
for (int i = linkedHashSet.size(); i > 0; i --) {
System.out.println(i + " ");
}
}
}
}