Compute longest path beginning from all cells
for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if ( dp [ i ] [ j ] == - 1 ) : NEW_LINE INDENT findLongestFromACell ( i , j , mat , dp ) NEW_LINE DEDENT DEDENT DEDENT