Python Basic DFS

  • 0
    class Solution(object):
        def findSubsequences(self, nums):
            ans = []
            self.helper(ans, nums, [], 0)
            return ans
        def helper(self, ans, nums, temp, pos):
            if len(temp) >= 2:
            visited = set()
            for i in range(pos, len(nums)):
                if not temp or temp[-1] <= nums[i]:
                    if nums[i] not in visited:
                        self.helper(ans, nums, temp+[nums[i]], i+1)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.