※ 引述《Rushia (みけねこ的鼻屎)》之铭言:
: 1727. Largest Submatrix With Rearrangements
补写作业
结果想半天想不出办法
只能抄作业
记起来以后再来补交一次
TS Code:
function push<T> (arr: T[], ele: T): T[] {
arr.push(ele)
return arr
}
function largestSubmatrix (matrix: number[][]): number {
return matrix
.reduce<number[][]>((newMat, curArr, i) => push(newMat, curArr
.reduce<number[]>((newArr, cur, j) => push(newArr, cur === 1 && i > 0 ?
cur += newMat[i - 1][j] : cur), [])), [])
.reduce((result, row) => Math
.max(result, row
.sort((a, b) => b - a)
.reduce((result, num, i) => Math
.max(result, num * (i + 1)), 0)), 0)
}
写到后面我已经不知道在写什么了
一大堆callback
我需要curry