11 lines concise and easy understand c++ solution
class Solution {\n    public:\n        bool isValidSerialization(string preorder) {\n            istringstream iss(preorder);\n            int nullcnt = 0, node
    class Solution {\n    public:\n        bool isValidSerialization(string preorder) {\n            istringstream iss(preorder);\n            int nullcnt = 0, nodecnt = 0;\n            string tmp;\n            vector<string> vec;\n            while(getline(iss, tmp, ',')) vec.push_back(tmp);\n            for(int i = 0; i < vec.size(); i++){\n                if(vec[i] != "#") nodecnt++;\n                else nullcnt++;\n                if(nullcnt == nodecnt + 1 && i != vec.size() - 1) return false;\n            }\n            return nullcnt == nodecnt + 1;\n        }\n    };
[]