题解 | #小欧的数组修改#

小欧的数组修改

https://www.nowcoder.com/practice/9d57195bcec9415e9d12db846545ee0f

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int []arr=new int[n];
        int []count=new int[100010];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
            count[arr[i]]++;
        }
        if(n==1){
            System.out.print("1");
            return;
        }
if(n==2){
            System.out.print("2");
            return;
        }
        int max=0;
        for(int c:count){
            max=Math.max(c,max);
        }
        System.out.print(max+1);
    }
}

全部评论

相关推荐

07-25 10:17
仰恩大学 营销
bg双非,被挂了
投递拼多多集团-PDD等公司10个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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