[✅Intutive]✅Beginner Friendly Solution | | ✅without stringstream and getline | | ✅C++
\n\n# Code\n\nclass Solution {\npublic:\n    bool isValidSerialization(string preorder) {\n     preorder+=",";\n     vector<string> arr;\n     int n=preorder.si
\n\n# Code\n```\nclass Solution {\npublic:\n    bool isValidSerialization(string preorder) {\n     preorder+=",";\n     vector<string> arr;\n     int n=preorder.size();\n     \n    int i=0;\n    while(i<n)\n    {\n        string p="";\n        while(preorder[i]!=\',\')\n        {\n            p+=preorder[i];\n            i++;\n        }\n        arr.push_back(p);\n        i++;\n    }\n\n\n\n     for(auto i:arr) cout<<i<<" ";\n     stack<string> st;\n        for(int i=0;i<arr.size();i++)\n        {\n            string p=arr[i];\n            \n            if(st.empty() || p!="#") st.push(p);\n            else\n            {\n                while(!st.empty() && st.top()=="#")\n                {\n                    st.pop();\n                    if(st.empty()) return false;\n                     else\n                      st.pop();\n                }\n                st.push(p);\n            }\n        }\n        return st.size() == 1 && st.top() == "#";\n    }\n        \n};\n```
['String', 'Stack', 'C', 'C++']