题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.close(); List<Integer> list = new ArrayList<>(); while (n > 0) { int digit = n % 10; if (!list.contains(digit)) { list.add(digit); } n /= 10; } int res = 0; for (int digit : list) { res = res * 10 + digit; } System.out.println(res); } }