22栈的压入,弹出序列
来源:互联网 发布:淘宝注册怎么注册账号 编辑:程序博客网 时间:2024/06/07 05:09
bool IsPopOrder(const int* pPush, const int* pPop, int nLength)
{
bool bPossible = false;
if (pPush != NULL&&pPop != NULL&&nLength > 0)
{
const int* pNextPush = pPush;
const int* pNextPop = pPop;
std::stack<int> stackData;
while (pNextPop - pPop < nLength)
{
while (stackData.empty() || stackData.top() != *pNextPop)
{
if (pNextPush - pPush == nLength)
break;//判断是否第一个序列全都压入栈
stackData.push(*pNextPush);
pNextPush++;
}
if (stackData.top() != *pNextPop)
break;
stackData.pop();
pNextPop++;
}
if (stackData.empty() && pNextPop - pPop == nLength)//第二个序列中还有元素
bPossible = true;
}
return bPossible;
}
0 0
- 22栈的压入,弹出序列
- 22 栈的压入,弹出序列
- 22、栈的压入、弹出序列
- 1366栈的压入弹出序列
- 栈的压入、弹出序列
- 栈的压入、弹出序列
- 栈的压入、弹出序列
- Q22:栈的压入、弹出序列
- 栈的压入弹出序列
- 栈的压入、弹出序列
- 栈的压入弹出序列
- 栈的压入、弹出序列
- 栈的压入弹出序列
- 栈的压入、弹出序列
- 栈的压入、弹出序列
- 栈的压入弹出序列
- 栈的压入、弹出序列
- 栈的压入和弹出序列
- Linux下git学习笔记(一)
- CNN for NLP 论文目录
- z-index属性
- mysql常用的东西
- ViewGroup的OnInterceptTouchEvent方法的调用特点
- 22栈的压入,弹出序列
- 在windows上编译scite
- C 指针
- C语言 用for语句老实现打印九九乘法口诀表
- poj 1681
- C++常用类 shared_ptr
- 凸优化:ADMM(Alternating Direction Method of Multipliers)交替方向乘子算法系列之二:Precursors
- 大型互联网架构概述
- 使用MYSQL benchmark - DBT2 Benchmark Tool遇到的问题