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

提取不重复的整数

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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = String.valueOf(n);
   
        List<Character> list = new ArrayList<>();
        for (int i = str.length()-1;i>=0;i--){
            if (list.contains(str.charAt(i))){
                continue;
            }
            list.add(str.charAt(i));
        }
        StringBuffer sb = new StringBuffer();
        for (char a:list
             ) {
  
            sb.append(a);
        }
        System.out.println(Integer.valueOf(sb.toString()));
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
Twilight_m...:还是不够贴近现实,中关村那块60平房子200万怎么可能拿的下来,交个首付还差不多
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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