注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
只copy了第三题,前2题都非常简单,凑合看吧
"""
Snakes make nests of open spaces, but they avoid connecting their nest with other snakes' nests. Each nest (consisting of one or more connected 0's) houses one snake only, though a single nest may have one or many entrances on the edges of the board, or possibly none at all. Each 0 for a nest that is on an edge counts as its own entrance, even if two or more of them are next to one another.
Here is an example board:
col--> 0 1 2 3 4 5 6 7 8
+-------------
getNestEntranceCount(board1) => [2, 5]
getNestEntranceCount(board2) => [1, 1]
getNestEntranceCount(board3) => [2, 4, 3]
getNestEntranceCount(board4) => [0]
getNestEntranceCount(board5) => []
getNestEntranceCount(board6) => [4]
Complexity Analysis:
r: number of rows in the board
c: number of columns in the board
""" |