Module Expr Str Assign NameStore Str ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore ListLoad Expr Call AttributeLoad NameLoad attr NameLoad Num NameLoad ListLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If BoolOpAnd CompareEq Call NameLoad NameLoad NameLoad CompareEq NameLoad Num body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Return If BoolOpOr CompareGtE NameLoad Call NameLoad NameLoad CompareGt Call NameLoad NameLoad NameLoad CompareLt BinOpAdd BinOpSub Call NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad body Return Expr Call AttributeLoad NameLoad attr NameLoad BinOpAdd NameLoad Num NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad Expr Call AttributeLoad NameLoad attr NameLoad BinOpAdd NameLoad Num NameLoad NameLoad BinOpSub NameLoad SubscriptLoad NameLoad Index NameLoad NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If BoolOpAnd CompareEq Call NameLoad NameLoad NameLoad CompareEq NameLoad Num body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad If BoolOpOr UnaryOpNot NameLoad CompareGtE Call NameLoad NameLoad NameLoad CompareLt BinOpAdd Call NameLoad NameLoad Call NameLoad NameLoad NameLoad body Return Assign NameStore Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad BinOpSub NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If BoolOpAnd CompareEq Call NameLoad NameLoad NameLoad CompareEq NameLoad Num body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad If BoolOpOr UnaryOpNot NameLoad CompareGtE Call NameLoad NameLoad NameLoad CompareLt BinOpAdd Call NameLoad NameLoad Call NameLoad NameLoad NameLoad body Return Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad BinOpSub NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad decorator_list decorator_list If CompareEq NameLoad Str body Print Call AttributeLoad Call NameLoad attr ListLoad Num Num Num Num Num Num Assert CompareEq Call AttributeLoad Call NameLoad attr ListLoad Num Num Num Num Num Num ListLoad ListLoad Num Num ListLoad Num Num
N/A N/A 
Given n unique integers, number k (1<=k<=n)  and target. Find all possible k integers where their sum is target.

Example
Given [1,2,3,4], k=2, target=5, [1,4] and [2,3] are possible solutions.
 N/A __author__ Danyang Solution N/A object N/A kSumII N/A N/A self A k target N/A N/A N/A 
        brute force dfs
        Branch and prune

        :param A: An integer array.
        :param k: a positive integer (k <= length(A))
        :param target: int
        :return: int
         N/A ret N/A N/A N/A N/A self dfs A 0 k N/A target ret N/A ret N/A dfs N/A N/A self A i k cur remain ret N/A N/A N/A self.dfs(A, 0, k, [], target, ret) N/A N/A N/A N/A len cur k N/A remain 0 N/A N/A N/A N/A ret append N/A list cur N/A N/A N/A N/A i N/A len A N/A N/A len cur k N/A N/A N/A N/A len A i N/A len cur k N/A N/A N/A N/A N/A self dfs A N/A i 1 k cur remain ret N/A N/A N/A cur append N/A A N/A i N/A N/A N/A self dfs A N/A i 1 k cur N/A remain N/A A N/A i ret N/A N/A N/A cur pop N/A dfs_array N/A N/A self A k cur remain ret N/A N/A N/A 
        self.dfs_array(A, k, [], target, ret)
         N/A N/A N/A N/A len cur k N/A remain 0 N/A N/A N/A N/A ret append N/A list cur N/A N/A N/A A N/A N/A len cur k N/A N/A N/A len A N/A len cur k N/A N/A N/A num N/A N/A A pop 0 N/A N/A N/A self dfs_array A k cur remain ret N/A N/A N/A cur append num N/A N/A N/A self dfs_array A k cur N/A remain num ret N/A N/A N/A cur pop N/A N/A N/A A push 0 num N/A dfs_stk N/A N/A self A k cur remain ret N/A N/A N/A 
        self.dfs_stk(A[::-1], k, [], target, ret)
        since array insert takes O(n), speed up by using stack
         N/A N/A N/A N/A len cur k N/A remain 0 N/A N/A N/A N/A ret append N/A list cur N/A N/A N/A A N/A N/A len cur k N/A N/A N/A len A N/A len cur k N/A N/A N/A num N/A N/A A pop N/A N/A N/A self dfs A k cur remain ret N/A N/A N/A cur append num N/A N/A N/A self dfs A k cur N/A remain num ret N/A N/A N/A cur pop N/A N/A N/A A append num N/A N/A N/A N/A __name__ __main__ N/A N/A N/A N/A N/A Solution kSumII N/A 1 2 3 4 2 5 N/A N/A N/A N/A N/A Solution kSumII N/A 1 2 3 4 2 5 N/A N/A 3 2 N/A 1 4