Very intuitive Java solution
public boolean isValidSerialization(String preorder) {\n        String[] strs = preorder.split(",");\n        Stack<String> stack = new Stack<>();\n        for(
    public boolean isValidSerialization(String preorder) {\n        String[] strs = preorder.split(",");\n        Stack<String> stack = new Stack<>();\n        for(int i = 0; i < strs.length; i++) {\n            stack.push(strs[i]);\n            if (stack.size() >= 3) {\n                if(!helper(stack)) return false;\n            }\n        }\n        return stack.size() == 1 && stack.peek().equals("#");\n    }\n    \n    private boolean helper(Stack<String> stack) {\n        String top = stack.pop();\n        String second = stack.peek();\n        stack.push(top);\n        while (!stack.isEmpty() && stack.peek().equals("#") && second.equals("#")) {\n            stack.pop(); // first #\n            stack.pop(); // second #\n            if(stack.peek().equals("#")) {\n                return false; // "#, #, #"\n            } else {\n                stack.pop(); // pop a number\n                if(stack.size() >= 2) {\n                    second = stack.peek();\n                    stack.push("#");\n                } else {\n                    stack.push("#");\n                    break;\n                }\n            }\n        }\n        return true;\n    }
[]