//普通hashset,解法 import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int num = sc.nextInt(); HashSet<integer> hashtable = new HashSet<>(); int res = 0; int temp = 0; while(num / 10 != 0){ temp = num % 10; num /= 10; if(!hashtable.contains(temp)){ res = res * 10 + temp; hashtable.add(temp); } } if(!hashtable.contains(num)){//最后一个数字 res = res * 10 + num; } System.out.println(res); } }</integer>
点赞

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务