Backtracking
for j in range ( len ( v ) ) : NEW_LINE INDENT if ( v [ j ] >= q [ i ] ) : NEW_LINE INDENT v [ j ] -= q [ i ] NEW_LINE if ( getans ( i + 1 , v , q ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT v [ j ] += q [ i ] NEW_LINE DEDENT DEDENT return False NEW_LINE