题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); int x; int n = fzhinput.nextInt(); StringBuilder stack = new StringBuilder(); Set <Integer> seen = new HashSet<>(); while(n>10){ x = n%10; if(!seen.contains(x)){ stack.append(x); seen.add(x); } n/=10; } if(!seen.contains(n)){ stack.append(n); seen.add(n); } System.out.println(stack); } }