Following steps build LCSuff [ m + 1 ] [ n + 1 ] in bottom up fashion .
for i in range ( m + 1 ) : NEW_LINE INDENT for j in range ( n + 1 ) : NEW_LINE INDENT if i == 0 or j == 0 : NEW_LINE INDENT LCSuff [ i ] [ j ] = 0 NEW_LINE DEDENT elif X [ i - 1 ] == Y [ j - 1 ] : NEW_LINE INDENT LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1 NEW_LINE if length < LCSuff [ i ] [ j ] : NEW_LINE INDENT length = LCSuff [ i ] [ j ] NEW_LINE row = i NEW_LINE col = j NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT LCSuff [ i ] [ j ] = 0 NEW_LINE DEDENT DEDENT DEDENT