8-line Python non-recursive solution using stack, replace (number, #, #) with #, very easy to understand
def isValidSerialization(self, preorder):\n        stack = []\n        for value in preorder.split(','):\n            if value == '#':\n                while le
    def isValidSerialization(self, preorder):\n        stack = []\n        for value in preorder.split(','):\n            if value == '#':\n                while len(stack) >= 2 and stack[-1] == '#' and stack[-2] != '#':\n                    stack.pop()\n                    stack.pop()\n            stack.append(value)\n        return stack == ['#']
['Stack', 'Python']