Help with this problem please! (Python)
Can someone please explain why unpacking the generator "intervals" gets the correct answer (but TLE), but when I unpack it in the for loop it gets WA (but not T
Can someone please explain why unpacking the generator "intervals" gets the correct answer (but TLE), but when I unpack it in the for loop it gets WA (but not TLE)?\n\nEven if I change the for loop to "for x, y in [[x[0], x[1] for x in intervals]:...", I still get WA.\n\n```\nclass Solution:\n    def smallestMissingValueSubtree(self, parents: List[int], nums: List[int]) -> List[int]:\n        d = defaultdict(list)\n        N = len(parents)\n        ans = [0 for x in range(N)]\n        \n        for i in range(N):\n            d[parents[i]].append(i)        \n        \n        def go(node):\n            intervals = [[nums[node], nums[node]]]\n            heapify(intervals)\n                        \n            for child in d[node]:\n                intervals = merge(intervals, go(child))\n            \n            #######why does unpacking the generator give the right answer???\n            #with the line below this I get the correct answer, but too slow\n            #without the line below I get WA\n            intervals = [[x[0], x[1]] for x in intervals]\n            \n            out = []\n            curry = 0\n            currx = 1\n            mini = None\n            for x, y in intervals:\n                if x == curry + 1:\n                    curry = y\n                else:\n                    if not mini:\n                        mini = curry + 1\n                    out.append([currx, curry])\n                    currx = x\n                    curry = y\n                    \n            if not mini:\n                mini = curry + 1\n            \n            ans[node] = mini\n            \n            return intervals\n            \n        go(0)\n        return ans
[]