JAVA, Counting Indegree and Outdegree, SIMPLE & CLEAR!
 public boolean isValidSerialization(String preorder) {\n        String[] strs = preorder.split(",");\n        int degree = -1;         // root has no indegree,
     public boolean isValidSerialization(String preorder) {\n        String[] strs = preorder.split(",");\n        int degree = -1;         // root has no indegree, for compensate init with -1\n        for (String str: strs) {\n            degree++;             // all nodes have 1 indegree (root compensated)\n            if (degree > 0) {     // total degree should never exceeds 0\n                return false;\n            }      \n            if (!str.equals("#")) {// only non-leaf node has 2 outdegree\n                degree -= 2;\n            }  \n        }\n        return degree == 0;\n    }
[]