Verify Preorder Serialization of a Binary Tree
bool isValidSerialization(string preorder) {
string replaced = std::regex_replace(preorder, (regex)"\\d+,#,#", "#");
return replaced == "#" || (replaced != preorder && isValidSerialization(replaced));
}