Verify Preorder Serialization of a Binary Tree
来源:互联网 发布:影视飞飞cms 编辑:程序博客网 时间:2024/05/01 10:20
bool isValidSerialization(string preorder) { int len = preorder.size(); vector<char> temp; bool flag = true; for (int i = 0; i < len; i++) { if (flag == true) { temp.push_back(preorder[i]); flag = false; } if (preorder[i] == ',') { flag = true; continue; } int sz = temp.size(); while (sz > 1 && temp[sz - 1] == '#'&&temp[sz - 2] == '#') { temp.pop_back(); temp.pop_back(); if (temp.empty()) return false; temp.pop_back(); temp.push_back('#'); sz = temp.size(); } } return temp.size()==1&&temp[0]=='#';}
0 0
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- Verify Preorder Serialization of a Binary Tree
- leetcode Verify Preorder Serialization of a Binary Tree
- 331. Verify Preorder Serialization of a Binary Tree
- Leetcode: Verify Preorder Serialization of a Binary Tree
- LeetCode Verify Preorder Serialization of a Binary Tree
- leetcode 331. Verify Preorder Serialization of a Binary Tree
- [LeetCode]331. Verify Preorder Serialization of a Binary Tree
- 331. Verify Preorder Serialization of a Binary Tree
- [leetcode] Verify Preorder Serialization of a Binary Tree
- struct和typedef struct
- 复变函数
- Bias-Variance Tradeoff【转载】
- MFC 实现单进程运行
- 安装服务时遇到 System.BadImageFormatException: 未能加载文件或程序集
- Verify Preorder Serialization of a Binary Tree
- [iOS]实现抽象基类
- iOS 定位服务编程详解
- mac mysql忘记root密码
- 深入使用Spring(一)
- eclipse+SVN文件只显示版本号,不显示时间和作者解决办法
- MySQL存储引擎对比
- php 学习笔记 -- 日期(四)
- 一个不错的android学习网站