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

相关推荐

14 1 评论
分享
牛客网
牛客企业服务