dp [ i ] [ j ] Stores length of longest consecutive path starting at arr [ i ] [ j ] .
let dp = new Array ( R ) ; for ( let i = 0 ; i < R ; i ++ ) { dp [ i ] = new Array ( C ) ; for ( let j = 0 ; j < C ; j ++ ) { dp [ i ] [ j ] = 0 ; } }