1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
function solution(board) { var answer = 1;
var lownum = board.length; var colnum = board[0].length; console.log(lownum, colnum);
if (lownum == 1 || colnum == 1) { var maxRow = board.map(function (row) { return Math.max.apply(null, row); }); var max = Math.max.apply(null, maxRow);
return max; }
var max = 0;
for (var q = 1; q < board.length; q++) { for (var w = 1; w < board[0].length; w++) { if (board[q][w] == 0) { continue; } var arr = [board[q - 1][w - 1], board[q - 1][w], board[q][w - 1]]; board[q][w] = Math.min.apply(null, arr) + 1; max = Math.max(max, board[q][w]); } }
answer = max * max;
console.log(answer); return answer; }
|