Easy java recursive solution, just follow what preorder does
Version 2: without global variable:\n\n    public class Solution {\n    \tpublic boolean isValidSerialization(String preorder) {\n    \t\tint[] pos = new int[]{
Version 2: without global variable:\n\n    public class Solution {\n    \tpublic boolean isValidSerialization(String preorder) {\n    \t\tint[] pos = new int[]{-1};\n    \t\tString[] s = preorder.split(",");\n    \t\treturn isValid(s, pos) && pos[0] == s.length - 1;\n        }\n    \tprivate boolean isValid(String[] s, int[] pos){\n            if (++pos[0]>= s.length) return false;\n            if (s[pos[0]].equals("#")) return true;        \t\n    \t\t//verify left and right node\n            return isValid(s, pos) && isValid(s, pos);\n    \t}\n    }\n\n\nOriginal version below:\n\nThe idea is to verify the root, the left and right. I am still learning java, let me know if this can be improved.\n\n    public class Solution {\n    \tint pos = -1;\n    \tpublic boolean isValidSerialization(String preorder) {\n    \t\tString[] s = preorder.split(",");\n    \t\treturn isValid(s) && pos == s.length - 1;\n        }\n    \tprivate boolean isValid(String[] s){\n            if (++pos >= s.length) return false;\n            if (s[pos].equals("#")) return true;\n\t\t\t//verify left and right node\n            return isValid(s) && isValid(s);\n    \t}\n    }
['Java']