Simple Python Solution (792 ms)


  • 0
    S
    def findSubsequences(self, nums):
        if len(nums) < 2:
            return []
            
        def f(i, arr):
            if i == len(nums): return
            x = nums[i]
            tmp = [[x]]
            for a in arr:
                if len(a) > 0 and x >= a[-1]:
                    tmp.append(a + [x])
            arr.extend(tmp)
            f(i+1, arr)
    
        arr = [[]]
        f(0, arr)
        
        return list(set([tuple(x) for x in arr if len(x) > 1]))
    

Log in to reply
 

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