注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 美帝马甲 于 2020-11-26 10:13 编辑
2题都是面经题时间很紧,开始问我项目,问了10分钟,然后说写代码45分钟。
第一题,出了个笔误g[j][i]误写成g[i][j]了,debug了5-6分钟,浪费了点时间。
不过后来还是做出了2题
注意,karat的特点是不管你用什么技巧,但一定要出正确结果。
所以我都是裸bruce了2题。
对面的面试官要我run所有的test case,过了才给下一题。
第二题完了还剩5分钟。
出了第三题。也是个board题,
对方说尽量给出一点idea,对会算作面试成绩
我就说了用bfs的迷宫找路思路。只有5分钟了也没时间写代码了。
第一题
给一个N*N的矩阵,判定是否是有效的矩阵。有效矩阵的定义是每一行或者每一列的数字都必须正好是1到N的数。输出一个bool。
第二题
A nonogram is a logic puzzle, similar to a crossword, in which the player is given a blank grid and has to color it according to some instructions. Specifically, each cell can be either black or white, which we will represent as 0 for black and 1 for white.
+------------+
| 1 1 1 1 |
| 0 1 1 1 |
| 0 1 0 0 |
| 1 1 0 1 |
| 0 0 1 1 |
+------------+
For each row and column, the i
"""
matrix1 = [
[1,1,1,1], # []
[0,1,1,1], # [1] -> a single run of _1_ zero (i.e.: "0")
[0,1,0,0], # [1, 2] -> first a run of _1_ zero, then a run of _2_ zeroes
[1,1,0,1], # [1]
[0,0,1,1], # [2]
]
# True
rows1_1 = [[],[1],[1,2],[1],[2]]
columns1_1 = [[2,1],[1],[2],[1]]
# False
rows1_2 = [[],[],[1],[1],[1,1]]
columns1_2 = [[2],[1],[2],[1]]
matrix2 = [
[1,1],
[0,0],
[0,0],
[1,0]
]
# False
rows2_1 = [[],[2],[2],[1]]
columns2_1 = [[1,1],[3]]
|