def dfs_TLE(self, A, k, target, cur, ret):
        if len(cur) == k and sum(cur) == target:  # possible to optimized
            ret[0] += 1

        if not A or len(cur) >= k:
            return

        # if save space, you need to do the clean up
        num = A.pop(0)
        self.dfs_TLE(A, k, target, cur, ret)
        A.push(0, num)

        num = A.pop(0)
        cur.append(num)
        self.dfs_TLE(A, k, target, cur, ret)
        cur.pop()
        A.push(0, num)
dataset/ETHPy150Open algorhythms/LintCode/k Sum.py/Solution.dfs_TLE/original