海洋中岛屿数量问题 算法
const getIslands = (arr = []) => {
const len = arr.length;
const counter = 0;
while(len) {
let row = arr[arr.length - len];
// let item;
let num = 0;
let cur = 0;
for (let i = 0; i < row.length; i++) {
let item = row[i];
if(item === `+`) {
num +=1;
let netxItem = row[i + 1];
// const nextRow = arr[arr.length - len + 1];
// let nextRowitem = nextRow[i];
if(item === netxItem) {
break;
}
}
}
}
}
refs
https://leetcode.com/problems/number-of-islands
https://leetcode-cn.com/problems/number-of-islands/
DFS
https://zhuanlan.zhihu.com/p/133390668
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!