C++||100% faster|||O(n)||O(1)
\nclass Solution {\npublic:\n    bool isValidSerialization(string arr) {\n        int a=0,b=0;\n        for(int i=0;i<arr.size();i++){\n            if(b>a)\n   
```\nclass Solution {\npublic:\n    bool isValidSerialization(string arr) {\n        int a=0,b=0;\n        for(int i=0;i<arr.size();i++){\n            if(b>a)\n                return false;\n            if(arr[i]==\'#\')\n                b++;\n            else\n                a++;\n            while(i<arr.size()&&arr[i]!=\',\')\n                i++;\n        }\n        return a==b-1;;\n    }\n};\n```
[]