0%

美团20250426笔试

单选10题30分(有6题大模型相关的选择),编程题70分

单选

  1. 根据前序、中序获得后序序列
  2. 曼彻斯特编码和归零编码
    曼彻斯特编码:从低到高跳变表示“1”,从高到低跳变表示“0”
    归零编码:每个比特周期内,信号电平必须归零
  3. 60MB空间,动态分区存储,使用最先匹配算法,求最小空闲分区是多大
    分配过程:分配10MB,30MB 释放10MB,分配5MB
    最先匹配是从起始地址找第一个空闲分区
  4. 折半查找最坏第i次查成功元素最多为:
    第i次查找意味着元素在树的第i层上,最多有2^(i-1)个

编程

A2道

  1. 她有n个行李物品,每个行李物品用小写字母表示。 现在规定每种行李物品携带不能超过个,求小美最多可以带多少个行李物品。
  2. 找规律推理,根据题目意思打印了几个值,找到规律后再写的
    题目:https://niumacode.com/problem/P1600
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
        public static void main(String[] args) {  
    int n = 15;
    long[] pow = new long[] {1, 2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824};
    long sum = 0;
    int x = n;
    int count = 0;
    while(x != 0) {
    count ++;
    x /= 2;
    }
    System.out.println(count - 1);
    int y = n - (int)Math.pow(2, count - 1);
    for(int i = 0; i < count - 1; i ++ ) {
    sum += (long)pow[i] * (pow[i + 1] - 1);
    }
    sum += (long)(y + 1) * ((long)(pow[count] - 1));

    System.out.println(sum);
    }
    }
  3. https://niumacode.com/problem/P1601