Maximum length sub - sequence of ( 0. . 1. . )
for i in range ( 1 , n ) : NEW_LINE INDENT if arr [ i ] == 1 : NEW_LINE INDENT dp [ 1 ] [ i ] = max ( dp [ 1 ] [ i - 1 ] + 1 , dp [ 0 ] [ i - 1 ] + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT dp [ 1 ] [ i ] = dp [ 1 ] [ i - 1 ] NEW_LINE DEDENT DEDENT