7 lines c++ Easy peasy 0 ms
Explaination in Comments\uD83D\uDE0E\n```\nclass Solution {\npublic:\n    bool isValidSerialization(string preorder){\n\t// declaring n means we are thinking of
# Explaination in Comments\uD83D\uDE0E\n```\nclass Solution {\npublic:\n    bool isValidSerialization(string preorder){\n\t// declaring n means we are thinking of that atleast we have head in imginary BT/\\.\n        int n=1,size=preorder.size(),i=0;\n        preorder+=\',\';\n\t\t// Doing this will help in traversing the string.\n\t\t// i have also used the stringstream getline which takes 7ms but i have done this in 0ms according to leet code O(sizeofstring);\n        while(i<size){\n            string temp="";\n\t\t\t// this while loop is get the node val between two\',\'node val \',\'\n            while(preorder[i]!=\',\'){\n                temp+=preorder[i];\n                i++;\n            }\n            n--;\n            if(n<0) return false;\n\t\t\t// As for any node there are two mode node left or right either they are null node or not\n            if(temp!="#") n+=2;\n            i++;\n        }\n        return n==0;\n    }\n};
['C++']