1/**2* @param {string} preorder3* @return {boolean}4*/5var isValidSerialization = function (preorder) {6let balance = 1;7for (const node of preorder.split(","))8if (balance > 0)9if (node === "#") --balance;10else ++balance;11else return false;12return balance < 1;13};