这一题对我来说有些难度,起码是要看题解才能明白的程度,其核心思路就是从二维数组来设计,得到其最大长度,一行一行的从上往下,或从下往上进行填充要求rows * cols != length 无效let nums = [19, 10, 3, 7, 9, 8, 5, 2, 1, 17, 16, 14, 12, 18, 6, 13, 11, 20, 4, 15]
let rowsCount = 5
let colsCount = 4
/*
[
[19,17,16,15],
[10,1,14,4],
[3,2,12,20],
[7,5,18,11],
[9,8,6,13]
]
*/题解Array.prototype.snail = function (rowsCount, colsCount) {
if (rowsCount * colsCount !== this.length) return false;
let resAry = Array.from({ length: rowsCount }, () => []); // 创建对应二维数组
let seq
Harexs