1351-count-negative-numbers-in-a-sorted-matrix

DevGod
Vtuber
/** * @param {number[][]} grid * @return {number} */
//Bettervar countNegatives = function(grid) { let amount = 0; for(let A of grid){ label: for(let B = A.length-1; B >= 0; B+=-1){ if(A[B] < 0){ amount++;} else{ break label; } } } return amount;};
//Bruteforcevar countNegatives2 = function(grid) { let amount = 0; for(let A of grid){ for(let B of A){ if(B < 0){ amount++; } } } return amount;};