Python straightforward stack
\nclass Solution:\n    def isValidSerialization(self, preorder: str) -> bool:\n        stack = []\n        for c in preorder.split(\',\'):\n            stack.ap
```\nclass Solution:\n    def isValidSerialization(self, preorder: str) -> bool:\n        stack = []\n        for c in preorder.split(\',\'):\n            stack.append(c)\n            while stack[-2:] == [\'#\', \'#\']:\n                stack.pop()\n                stack.pop()\n                if not stack: return False\n                stack.pop()\n                stack.append(\'#\')\n        return stack == [\'#\']\n```
[]