C++ | Simple 4-line code | 4ms
\tclass Solution {\n\tpublic:\n\t\tbool isValidSerialization(string p)\n\t\t{\n\t\t\tint c = 1;\n\t\t\tfor(int i = 0; i < p.length(); ++i)\n\t\t\t{if(c <=0)retu
\tclass Solution {\n\tpublic:\n\t\tbool isValidSerialization(string p)\n\t\t{\n\t\t\tint c = 1;\n\t\t\tfor(int i = 0; i < p.length(); ++i)\n\t\t\t{if(c <=0)return false; if(p[i] == \'#\') --c; else ++c; while(i < p.length() && p[i]!=\',\') ++i;}\n\t\t\treturn (c == 0) ? true : false;\n\t\t}\n\t};
[]