以下均为本人回忆,可能和原题有出入。笔试分为选择与编程题,选择20道,编程3道。

一、选择

选择题考察了数据结构,算法,java,网络,mysql等知识。目前还记得题目大致为填写mysql语句,可能的出栈顺序,http&https。

选择题感觉是要寄,数据库一点没看,java的几道题也是猜猜

二、编程

  1. (签到题)给定正整数n,下面n行字符串代表访问的姓名,要求按照访问顺序给出无重复的姓名

    比较简单就不贴代码了了,我用Hashmap<Integer,String>存储结果,Integer在每次新增姓名时+1。

  2. 小红书推荐算法,给定正整数n与q,随后一行给出用户搜索的q的关键词,然后2*n行,每两行表示一个物品,第一行给出物品名字name和该物品的关键词数量m,随后一行给出m个关键词。请按照匹配的关键词数量对这些物品排序,对于匹配的关键词数量相同的,其顺序按照给出的顺序。

    4 5

    red book game music sigma

    mozart 3
    book classic music
    arcaea 4
    red music game hard

    对于上述样例,输出为:

    arcaea

    mozart

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.util.Comparator;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;


public class Main {
public static void main(String[] args) {
int n, q;
Scanner in = new Scanner(System.in);
n = in.nextInt();
q = in.nextInt();
HashSet<String> search = new HashSet<>();
PriorityQueue<as> map1 = new PriorityQueue<>(new Comparator<as>() {
@Override
public int compare(as o1, as o2) {
if (o1.count != o2.count) {
return o1.count - o2.count;
} else {
return o1.time - o2.time;
}
}
});
for (int i = 0; i < q; i++) {
String tmp = in.next();
search.add(tmp);
}
int time = 0;
for (int i = 0; i < n; i++) {
String name = in.next();
int m = in.nextInt();
int count = 0;
for (int j = 0; j < m; j++) {
String tmp = in.next();
if (search.contains(tmp)) {
count++;
}
}
time--;
as p = new as(name, count, time);
map1.offer(p);
}
Stack<String> res = new Stack<>();
for (int i = n - 1; i >= 0; i--) {
res.push(map1.poll().name);
}
while (!res.isEmpty()) {
System.out.println(res.pop());
}

}
}

class as {
public String name;
public int count;

public int time;

public as(String name, int count, int time) {
this.name = name;
this.count = count;
this.time = time;
}
}

  1. 给出一个正整数n,然后给出n条帖子的点赞数,这些帖子的点赞数过一段时间会增加,但是对于同一条帖子,其点赞数不能连续增加,请给出每条帖子的点赞数最大时,所有帖子的总点赞数。

    考试的时候没想出来,来点大佬想想