题解 | #提取不重复的整数#

提取不重复的整数

http://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1

import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n % 10 == 0){
            n = n / 10;
            if(n % 10 != 0){
                break;
            }
        }
        String str = n + "";
        String end = "";
        HashSet<Character> integer = new HashSet<>();
        ArrayList arrl = new ArrayList();
        for (int i = str.length() - 1; i >= 0; i--) {
            if(integer.add(str.charAt(i))){
                end = end + str.charAt(i);
            }
        }
        for (int i = 0; i < end.length() ; i++) {
            System.out.print(end.charAt(i));
        }
       

    }
}
全部评论

相关推荐

完美的潜伏者许愿简历...:隐藏信息被你提取出来了,暗示,这就是暗示
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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