0 ms C++ simple solution with counter
\nclass Solution {\npublic:\n    bool isValidSerialization(string preorder) {\n        int count = 0;\n        for(int i = 0 ; i < preorder.size() ; i++){\n    
```\nclass Solution {\npublic:\n    bool isValidSerialization(string preorder) {\n        int count = 0;\n        for(int i = 0 ; i < preorder.size() ; i++){\n            if(preorder[i] == \',\') continue;\n            \n            if(count < 0) return false;\n            \n            if(preorder[i] == \'#\')\n                count--;\n            else{\n                while(i < preorder.size() && preorder[i]!=\',\'  )\n                    i++;\n                count++;\n            }\n                \n        }\n        if(count == -1) return true;\n        return false;\n    }\n};\n```
['C', 'C++']