Implement the following operations of a stack using queues.
push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.
empty() -- Retur...
分类:
其他好文 时间:
2015-07-05 16:44:56
阅读次数:
148
1 题目描述:
有一个数组:2,1,4,3。对于数组,有一种操作op(idx):将该index对应的数字移到首位。比如:
op(3): 2 1 4 3 -> 3 2 1 4
op(1): 3 2 1 4 -> 2 3 1 4
op(2): 2 3 1 4 -> 1 2 3 4
问对于给定的数组,数组各个元素是任意的整数,可能有重复值,需要多少次OP操作,才能使得数组有序?...
分类:
编程语言 时间:
2015-07-05 13:46:46
阅读次数:
149
stack常用方法empty() 是否为空
size() 元素个数
pop() 删除栈顶元素
top() 返回栈顶元素的值
push() 增加元素stack st;
st.push("hello");
st.push("richard");
st.push("yang");
cout<<"the stack size is "<<st.size()<<...
分类:
其他好文 时间:
2015-07-05 09:35:20
阅读次数:
288
参考feliciafay代码如下:class MinStack {
private:
stack majorStack;
stack minorStack;
public:
void push(int x) {
majorStack.push(x); if(minorStack.empty() == true)...
分类:
其他好文 时间:
2015-07-04 18:30:03
阅读次数:
175
输入两个非负10进制整数A和B(//DEBUG 0 0 2#define MAXN 1000+50using namespace std;int a, b, d;stack s;int main(){ while(!s.empty()){ s.pop(); } sca...
分类:
其他好文 时间:
2015-07-04 11:07:14
阅读次数:
144
To summarize the default behavior for activities and tasks:When Activity A starts Activity B, Activity A is stopped, but the system retains its state ...
分类:
移动开发 时间:
2015-07-03 13:39:32
阅读次数:
110
题目:
Implement a basic calculator to evaluate a simple expression string.
The expression string may contain open ( and closing parentheses ),
the plus + or minus sign -, non-negative integers...
分类:
编程语言 时间:
2015-07-03 09:20:19
阅读次数:
143
Question:A Slice of an array said to be a Bounded slice if Max(SliceArray)-Min(SliceArray) stack = new LinkedList(); private Deque minStack = new L...
分类:
其他好文 时间:
2015-07-03 01:42:10
阅读次数:
208
#include"stdio.h"
#include"malloc.h"
#include"stdlib.h"
typedef struct lNode
{
char data;
struct lNode *lchild;
struct lNode *rchild;
}LNODE,*Tree;
typedef struct Node
{
Tree data;
struct Node * Next;
}NODE, * PNODE;
typedef struct Stack
{
...
分类:
其他好文 时间:
2015-07-02 19:30:39
阅读次数:
135
#include#includestruct Node;typedef struct Node *PtrToNode;typedef PtrToNode Stack;struct Node{ int Ele; PtrToNode Next;};StackCreateStack( void...
分类:
其他好文 时间:
2015-07-02 17:24:45
阅读次数:
99