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

提取不重复的整数

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

倒叙遍历字符串,使用contains判断是否重复

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String n = input.nextLine();
        String s = "";
        for(int i=n.length()-1;i>=0;i--){
            if(!s.contains(n.charAt(i)+"")){
               s= s + n.charAt(i);
            }
        }
        System.out.println(s);
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
昨天 12:15
门头沟学院 运营
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
昨天 12:09
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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