text: Finding GCD of each row and column and replacing with each element with maximum of GCD of row or column .
code: function replacematrix ( mat , n , m ) { let rgcd = new Array ( R ) ; rgcd . fill ( 0 ) ; let cgcd = new Array ( C ) ; cgcd . fill ( 0 ) ;