java solution
\nclass Solution {\n    public boolean isValidSerialization(String preorder) {\n        String[] nodes = preorder.split(",");\n        \n        int vacancy = 1
```\nclass Solution {\n    public boolean isValidSerialization(String preorder) {\n        String[] nodes = preorder.split(",");\n        \n        int vacancy = 1;\n        \n        for(String node : nodes){\n            // visiting node\n            vacancy--;\n            \n            // checking -ve case\n            if(vacancy<0) return false;\n            \n            // for non null node there is always a chance of two child\n            if(!node.equals("#")){\n                vacancy += 2;\n            }\n        }\n        return vacancy == 0;\n    }\n}\n```
[]