fix js螺旋数组

This commit is contained in:
mxdneu
2022-04-08 00:17:47 +08:00
parent 79b2453233
commit 1496b59646

View File

@ -246,11 +246,11 @@ var generateMatrix = function(n) {
res[row][col] = count++; res[row][col] = count++;
} }
// 下行从右到左(左闭右开) // 下行从右到左(左闭右开)
for (; col > startX; col--) { for (; col > startY; col--) {
res[row][col] = count++; res[row][col] = count++;
} }
// 左列做下到上(左闭右开) // 左列做下到上(左闭右开)
for (; row > startY; row--) { for (; row > startX; row--) {
res[row][col] = count++; res[row][col] = count++;
} }