Python DFS Beast 90%

  • 0
    class Solution(object):
        def findSubsequences(self, nums):
            :type nums: List[int]
            :rtype: List[List[int]]
            ans = []
            n = len(nums)
            def dfs(i, curr):
                if len(curr) > 1: 
                found = []
                for j in range(i+1, n):
                    if (i >= 0 and nums[j] < nums[i]) or nums[j] in found: continue
                    dfs(j, curr+[nums[j]])
            dfs(-1, [])
            return ans

Log in to reply

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