functioncountNegatives(grid:number[][]):number{let res =0;for(let i =0; i < grid.length;++i){for(let j =0; j < grid[i].length;++j){if(grid[i][j]<0){
res++;}}}return res;};
functionmaximumWealth(accounts:number[][]):number{let res =0;for(let i =0; i < accounts.length;++i){let num =0;for(let j =0; j < accounts[0].length;++j){
num += accounts[i][j];}
res = Math.max(num, res);}return res;};
functionsortDiagonal(mat, m, n, sr, sc){let r, c, x, temp =[]
r = sr, c = sc
while(r < m && c < n){
temp.push(mat[r][c])++r
++c
}
temp.sort((a, b)=> a - b)
r = sr, c = sc, x =0while(r < m && c < n){
mat[r][c]= temp[x++]++r
++c
}}functiondiagonalSort(mat:number[][]):number[][]{let m = mat.length
let n = mat[0].length
let i
for(i =0; i < m;++i){sortDiagonal(mat, m, n, i,0)}for(i =0; i < n;++i){sortDiagonal(mat, m, n,0, i)}return mat
};