题解 | #明明的随机数#

https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0

思路:以空间换时间

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int [] nums = new int[501];
        while(count>0){
            nums[sc.nextInt()]++;
            count--;
        }
        for(int i=1; i<=500; i++){
            if(nums[i]>0)
                System.out.println(i);
        }
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务