注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
刚面的roblox电面
第一题是valid sudoku 简易版
第二题如下,就是看每个row 和col里面连续B的数量是否跟input的array显示一样。时间有点仓促没写完,这道题tricky的点是什么时候move to the next input.
求大米!!
/*
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 'B' for black and 'W' for white.
+------------+
| W W W W |
| B W W W |
| B W B B |
| W W B W |
| B B W W |
+------------+
For each row and column, the instructions give the lengths of contiguous runs of black ('B') cells. For example, the instructions for one row of [ 2, 1 ] indicate that there must be a run of two black cells, followed later by another run of one black cell, and the rest of the row filled with white cells.
These are valid solutions: [ W, B, B, W, B ] and [ B, B, W, W, B ] and also [ B, B, W, B, W ]
This is not valid: [ W, B, W, B, B ] since the runs are not in the correct order.
This is not valhe black cells in the first column are not separated by white cells.
Example instructions #6
(same matrix as above)
rows2_2 = [], [2], [2], [1]
columns2_2 = [3], [3]
validateNonogram(matrix2, rows2_2, columns2_2) => False
The first column has the wrong number of black cells.
Example instructions #7
(same matrix as above)
rows2_3 = [], [], [], []
columns2_3 = [], []
validateNonogram(matrix2, rows2_3, columns2_3) => False
All of the instructions are empty
n: number of rows in the matrix
m: number of columns in the matrix
*/
|