Java recursion solution
Main idea is checking balance of nodes from bottom-up manner and bubble up failure condition.\n\n    public class Solution {\n    \tpublic boolean isValidSerial
Main idea is checking balance of nodes from bottom-up manner and bubble up failure condition.\n\n    public class Solution {\n    \tpublic boolean isValidSerialization(String preorder) {\n    \t\tString[] tree = preorder.split(",");\n    \t\treturn valid(tree, 0) == tree.length-1;\n    \t}\n    \n    \tprivate int valid(String[] tree, int current) {\n    \t\tif(current >= tree.length) return -1;\n    \t\tif("#".equals(tree[current])) return current;\n    \n    \t\t// left\n    \t\tint next = valid(tree, current + 1);\n    \t\tif(next == -1) return -1;\n    \n    \t\t// right\n    \t\tnext = valid(tree, next + 1);\n    \t\treturn next == -1 ? -1 : next;\n    \t}\n    }
['Recursion']