网易云音乐 Android开发 笔经

2020.08.08 下午 笔试 1h40min

1)关键词

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double cnt = ((double) n) * 0.01;
        Map<String, Integer> map = new HashMap<>();
        Set<String> set = new HashSet<>();
        for(int i = 0; i < n; i++){
            String str = sc.nextLine();
            if(set.contains(str)) {
                continue;
            }

            if(!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                map.put(str, map.get(str) + 1);
            }

            if((double) map.get(str) >= cnt) {
                set.add(str);
            }
        }

        System.out.println(set.size());
    }
}


2)牛牛铺地毯

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] a = new int[t];
        int max = 0;
        for (int i = 0; i < t; i++) {
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
        }

        if(max == 1) {
            for (int i = 0; i < t; i++) {
                System.out.println(1);
            }
            return;
        }

        int[] dp = new int[max + 1];
        dp[0] = 1;
        dp[1] = 1;
        dp[2] = 2;
        for (int j = 3; j <= max; j++) {
            dp[j] = (dp[j - 1] + dp[j - 2] + dp[j - 3]) % 10007;
        }

        for(int n : a) {
            System.out.println(dp[n]);
        }
    }
}


第一题90%,第三题100%,第二题不会做,第四题不会做。

#笔经##网易##安卓工程师##校招#
全部评论
跟楼主一样,我也是第一题只过了90%,不知问题出在哪了😂
点赞 回复
分享
发布于 2020-08-08 17:16
第一题100,其余的都没做出来
点赞 回复
分享
发布于 2020-08-08 19:22
联想
校招火热招聘中
官网直投
四道算法题,我估计考了个大鸭蛋😥
点赞 回复
分享
发布于 2020-08-08 19:49

相关推荐

2 2 评论
分享
牛客网
牛客企业服务