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

  • 0

    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)
        self._subsets(S, level+1)

    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.