r1 is the top row , c1 is the left col r2 is the bottom row , c2 is the right
function hasSquareOfZeroes ( matrix , r1 , c1 , r2 , c2 , cache ) { if ( r1 >= r2 c1 >= c2 ) return false ; var key = ( r1 . toString ( ) ) + ' ' + ( c1 . toString ( ) ) + ' ' + ( r2 . toString ( ) ) + ' ' + ( c2 . toString ( ) ) ; if ( cache . has ( key ) ) return cache . get ( key ) ; cache [ key ] = isSquareOfZeroes ( matrix , r1 , c1 , r2 , c2 ) || hasSquareOfZeroes ( matrix , r1 + 1 , c1 + 1 , r2 - 1 , c2 - 1 , cache ) || hasSquareOfZeroes ( matrix , r1 , c1 + 1 , r2 - 1 , c2 , cache ) || hasSquareOfZeroes ( matrix , r1 + 1 , c1 , r2 , c2 - 1 , cache ) || hasSquareOfZeroes ( matrix , r1 + 1 , c1 + 1 , r2 , c2 , cache ) || hasSquareOfZeroes ( matrix , r1 , c1 , r2 - 1 , c2 - 1 , cache ) ; return cache [ key ] ; }