题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
import java.util.*; /** *author:ljq */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 String num = in.nextLine(); StringBuilder sb = new StringBuilder(num); char[] ary = sb.reverse().toString().toCharArray(); HashSet<Integer> set = new HashSet<>(); for(int i = 0;i < ary.length;i++){ String s = ary[i] + ""; if(set.add(Integer.parseInt(s))){ System.out.print(s); } } } }