HashSet

提取不重复的整数

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

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        Set<Character> set = new HashSet<>();
        for(int i = s.length() - 1; i >= 0; i--) {
            if(set.add(s.charAt(i))) {
                System.out.print(s.charAt(i));
            }
        }
    }
}
全部评论
输入是int,不是string吧
点赞 回复 分享
发布于 2022-05-01 15:10

相关推荐

牛客38347925...:9,2学生暑期实习失利开始投小厂,给这群人整自信了
点赞 评论 收藏
分享
06-12 10:50
门头沟学院 Java
你的不定积分没加C:我怎么在学院群看到了同样的话
点赞 评论 收藏
分享
评论
14
1
分享

创作者周榜

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