text: Javascript Program to implement the above approach
code: let mat = new Array ( 1001 ) ; for ( let i = 0 ; i < 1001 ; i ++ ) { mat [ i ] = new Array ( 1001 ) ; for ( let j = 0 ; j < 1001 ; j ++ ) { mat [ i ] [ j ] = 0 ; } } let r , c , x , y ;