//普通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>
点赞

相关推荐

中电45所 测试开发岗 可以解决北京户口,提供员工宿舍,早 8 晚 5(不过一般会加班到7-8点,周六一般也会去,面试官说的) 硕士
点赞 评论 收藏
转发
牛客网
牛客企业服务