8 line Regex solution without building the tree
using System.Text.RegularExpressions;\n    \n    public class Solution {\n        public bool IsValidSerialization(string preorder) {\n            var t = Strin
    using System.Text.RegularExpressions;\n    \n    public class Solution {\n        public bool IsValidSerialization(string preorder) {\n            var t = String.Empty;\n            var r = new Regex(@"[0-9]+,\\#,\\#", RegexOptions.Compiled);\n            while (preorder != t)\n            {\n                t = preorder;\n                preorder = r.Replace(preorder, "#");\n            }\n            \n            return preorder == "#";\n        }\n    }
[]