领克物流面试经历 |高级软件工程师
总共有3轮。但是第一轮我没有通过。
第1轮
它是一个 2 小时的在线编码测试。他们有自己的想法来参加在线测试。
编译器不是用户友好的,所以在转到下一个问题之前要小心。提交后,您将无法编辑您的代码。如果您导航到下一个问题,则无需提交,您输入的所有代码都将被清除
问题 1:从给定的长度为 K 的字符串中找到唯一的 N 长度字符串
问题二:加本的爱
Gaben wants to spread his love for games to poor children in a rural village.
He bought n gaming consoles with him and wants to distribute one console to each child.
Each console contains a number of games.
He wants to ensure that all children get equal or almost equal number of games.
Though he prefers to give consoles with high number of games. This is called as Gaben’s love.
We need to find the maximum Gaben’s love for a given input.
For example, he brings n = 5 consoles where the number of games is g = [5, 4, 4, 8, 6].
There are c=3 children. The minimum difference between all consoles can be had with {5, 4, 4} from indices {0, 1, 2}.
We must get the difference in the following pairs: [{0, 1}, {0, 2}, {1, 2}]. We calculate Gaben’s love as:
index games mapping difference result
0 5 (0, 1), (0, 2) |5-4| + |5-4| 2
1 4 (1, 2) |4-4| 0
2 4
Total = 2
Gaben’s love = 100 – (2/(5+4+4))*100
= 100 – 15.38
= 84.62
= cieling(84.62) = 85
Please get the ceiling value of the resulting float.
If there are c=4 kids then:
Consoles to be selected are {5, 4, 4, 6} from indices {0, 1, 2, 4}. We must get the difference of the following pairs:
index games mapping difference result
0 5 (0, 1), (0, 2), (0, 4) |5-4| + |5-4| + |5-6| 3
1 4 (1, 2), (1, 4) |4-4| + |4-6| 2
2 4 (2, 4) |4-6| 2
4 6
n = 7
Gaben’s love = 100 – (7/(5+4+4+6))*100
= 100 – 36.84
= 63.16
= cieling(63.16) = 64
Please get the ceiling value of the resulting float.
Input:
First line is the number of consoles Gaben has n
Provide the number of games in each console
Lastly give the number of children c
Sample:
Input:
5
5
4
4
8
6
3
Output:
85
问题 3:
可用硬币数量有限的硬币找零问题
https://www.careercup.com/question?id=5692261441470464
Input :
int[] notes = {100, 200, 500, 2000};
int[] count = {11, 14, 33, 100};
int sum = 500;
Output :
100|200|500|2000
5, 0, 0, 0
3, 1, 0, 0
1, 2, 0, 0
0, 0, 1, 0
问题4:
生命游戏的宇宙是一个无限的二维正交网格,由方形细胞组成,每个细胞都处于两种可能状态中的一种,活的或死的,(或分别有人居住和无人居住)。每个单元格都与其八个相邻单元格交互,这些相邻单元格是水平、垂直或对角相邻的单元格。在时间的每一步,都会发生以下转换:
1. 任何少于两个活邻居的活细胞都会死亡,就像人口不足一样。
2. 任何有两个或三个活邻居的活细胞都可以活到下一代。
3. 任何有超过三个活邻居的活细胞都会死亡,就像人口过剩一样。
4. 任何只有三个活邻居的死细胞都会变成活细胞,就像通过繁殖一样。
初始模式构成系统的种子。第一代是通过将上述规则同时应用于种子中的每个细胞而创建的;出生和死亡同时发生,发生这种情况的离散时刻有时被称为滴答声。每一代都是前一代的纯函数。这些规则继续被重复应用以创造更多的世代。
输入:
Universe 表示为二维数组
1. 宇宙的大小 m
2. 宇宙的大小 n
3. 运行代数
4. 开始时的活细胞数量
5. 活细胞的坐标列表 (x, y)。
输入
5
5
4
3
2, 1
2, 2
2、3
结果
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0