def dfs_TLE_2(self, A, k, target, s, l, la, ret):
        """
        Optimized version of dfs
        acceptable in k Sum II but TLE in k Sum
        """
        if l == k and s == target:
            ret[0] += 1

        if not A or l >= k or la+l < k:
            return

        # if save space, you need to do the clean up
        num = A.pop(0)
        self.dfs_TLE_2(A, k, target, s, l, la-1, ret)
        self.dfs_TLE_2(A, k, target, s+num, l+1, la-1, ret)
        A.push(0, num)
dataset/ETHPy150Open algorhythms/LintCode/k Sum.py/Solution.dfs_TLE_2/original