题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
import java.util.Scanner; import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s =""; //List<String> list = new ArrayList<>(); Set<String> set = new LinkedHashSet<>(); int a = in.nextInt(); String str = String.valueOf(a); if(!"0".equals(str.substring(str.length()-1))){ for (int i = str.length()-1;i>=0;i--){ String substring = str.substring(i, i + 1); set.add(substring); } } //} for (String num : set){ s+=num; } System.out.println(s); } }