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

提取不重复的整数

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);
            }
        }  
    }
}

全部评论

相关推荐

ohs的小木屋:比不少实习待遇高了
点赞 评论 收藏
分享
06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
fRank1e:吓得我不敢去外包了,但是目前也只有外包这一个实习,我还要继续去吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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