Testcase "[1,2]" fail in OJ but success in my local machine(DFS solution)


  • 0
    L

    testcase "[1,2]" fail in OJ but success in my local machine, see my codes:

    class Solution:
    
    # @param S, a list of integer
    # @return a list of lists of integer
    sets = []
    s_set = []
    def subsets(self, S):
        self._subsets(sorted(S), 0)
        return Solution.sets
    
    def _subsets(self, S, level):
        if level == len(S):
            return Solution.sets.append(Solution.s_set[:])
    
        self._subsets(S, level+1)
        Solution.s_set.append(S[level])
        self._subsets(S, level+1)
        Solution.s_set.pop()
    

    From OJ:

    Input:	[1,2]
    Output:	[[],[0],[],[2],[1],[1,2]]
    Expected:	[[],[1],[2],[1,2]]

Log in to reply
 

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