Merge pull request #1217 from mxdneu/master

fix js螺旋数组
This commit is contained in:
程序员Carl
2022-05-02 10:33:54 +08:00
committed by GitHub

View File

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