Check if a given matrix is sparse or not | Count number of zeros in the matrix ; Driver Function
for ( let i = 0 ; i < m ; ++ i ) for ( let j = 0 ; j < n ; ++ j ) if ( array [ i ] [ j ] == 0 ) ++ counter ; return ( counter > parseInt ( ( m * n ) / 2 ) , 10 ) ; } let array = [ [ 1 , 0 , 3 ] , [ 0 , 0 , 4 ] , [ 6 , 0 , 0 ] ] ; let m = 3 , n = 3 ; if ( isSparse ( array , m , n ) ) document . write ( " " ) ; else document . write ( " " ) ;