Hash Table Start!

(1)Island Perimeter 解题思路: 在矩阵上循环并记录岛(1)的个数;如果当前节点是岛,则检查其是否具有任何右邻居或下邻居,有的话邻居计数加1 ;岛的周长结果为islands * 4 - neighbors * 2.(乘2的原因是因为一条边属于两个邻居)。 代码如下: 1 public class Solution { 2 public int islandPerime
相关文章
相关标签/搜索