当前位置: 首页>>代码示例>>C++>>正文


C++ MinStack::getMin方法代码示例

本文整理汇总了C++中MinStack::getMin方法的典型用法代码示例。如果您正苦于以下问题:C++ MinStack::getMin方法的具体用法?C++ MinStack::getMin怎么用?C++ MinStack::getMin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MinStack的用法示例。


在下文中一共展示了MinStack::getMin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    MinStack stack;
    stack.push(10);
    stack.push(6);
    stack.push(10);
    stack.push(20);
    stack.push(8);
    stack.push(10);
    stack.push(10);
    stack.push(-110);
    stack.push(10);
    cout << stack.top() << endl;
    cout << stack.getMin() << endl;
    stack.pop();
    stack.pop();
    stack.pop();
    stack.pop();
    stack.pop();
    stack.pop();
    stack.pop();
    stack.pop();
    stack.pop();
    stack.pop();
    cout << stack.top() << endl;
    cout << stack.getMin() << endl;
    return 0;
}
开发者ID:eschwabe,项目名称:interview-practice,代码行数:28,代码来源:min_stack.cpp

示例2: main

int main()
{
	/*push(2147483646),push(2147483646),push(2147483647),top,pop,getMin,pop,getMin,pop,push(2147483647),
	top,getMin,push(-2147483648),top,getMin,pop,getMin*/
	MinStack ms;
    ms.push(2147483646);
	ms.push(2147483646);
	ms.push(2147483647);
	ms.top();
	ms.pop();
	ms.getMin();
	ms.pop();
	ms.getMin();
	ms.pop();
	ms.push(2147483647);
	ms.top();
	ms.getMin();
	ms.push(-2147483648);
	ms.top();
	ms.getMin();
	ms.pop();
	ms.getMin();	
		
	return 0;
}
开发者ID:pkuzw,项目名称:LeetCode-Zhao-Wei-,代码行数:25,代码来源:Min+Stack.cpp

示例3: main

int main() {
	MinStack minStack;
	minStack.push(-2);
	minStack.push(0);
	minStack.push(-3);
	cout << minStack.getMin() <<  "--> Returns -3" << endl;
	minStack.pop();
	cout << minStack.top() << "--> Returns 0" << endl;
	cout << minStack.getMin() <<  "--> Returns -2" << endl;
}
开发者ID:eagle9,项目名称:palgo,代码行数:10,代码来源:shaun1.cpp

示例4: main

int main () {
    MinStack* obj = new MinStack();
    obj->push(0);
    obj->push(1);
    obj->push(0);
    obj->getMin();
    obj->pop();
    obj->getMin();
    return 0;
}
开发者ID:husterxsp,项目名称:leetcode,代码行数:10,代码来源:MinStack.cpp

示例5: MinStack

TEST(leetcode_155_min_stack, Basic)
{
    MinStack *minStack = new MinStack();
    minStack->push(-2);
    minStack->push(0);
    minStack->push(-3);
    EXPECT_EQ(-3, minStack->getMin());
    minStack->pop();
    EXPECT_EQ(0, minStack->top());
    EXPECT_EQ(-2, minStack->getMin());
}
开发者ID:duxins,项目名称:leetcode,代码行数:11,代码来源:155-min-stack.cpp

示例6: main

int main(){
    MinStack stack;
    stack.push(-2);
    stack.push(0);
    stack.push(-1);
    std::cout << stack.getMin() << std::endl;
    std::cout << stack.top() << std::endl;
    stack.pop();
    std::cout << stack.getMin() << std::endl;
    return 0;
}
开发者ID:lobalani,项目名称:algo,代码行数:11,代码来源:min-stack.cpp

示例7: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	MinStack stk;
	stk.push(0);
	stk.push(1);
	stk.push(0);
	int v1 = stk.getMin();
	stk.pop();
	int v2 = stk.getMin();
	cout << "v1 : " << v1 << ", v2 : " << v2 << endl;
	return 0;
}
开发者ID:lewsn2008,项目名称:leetcode,代码行数:12,代码来源:MinStack.cpp

示例8: main

int main(void)
{
	MinStack engine;
	engine.push(-2);
	engine.push(0);
	engine.push(-1);
	cout << engine.getMin() << '\n';
	cout << engine.top() << '\n';
	engine.pop();
	cout << engine.getMin() << '\n';
	return 0;
}
开发者ID:CaptainCan,项目名称:Leetcode,代码行数:12,代码来源:155+LL.cpp

示例9: main

int main() 
{
	MinStack minStack;
	minStack.push(-2);
	minStack.push(0);
	minStack.push(-3);
	cout << minStack.getMin() << endl; //   --> Returns -3.
	minStack.pop();
	cout << minStack.top() << endl;    //  --> Returns 0.
	cout << minStack.getMin() << endl; //   --> Returns -2.

    return 0;
}
开发者ID:sniperswang,项目名称:dev,代码行数:13,代码来源:test.cpp

示例10:

TEST_F(SolutionTest, case1) {
	MinStack mstack;
	for (int i = 100; i >= 0; i--) {
		mstack.push(i);
		EXPECT_EQ(mstack.getMin(), i);
		EXPECT_EQ(mstack.top(), i);
	}
	EXPECT_EQ(mstack.getMin(), 0);
	EXPECT_EQ(mstack.top(), 0);
	mstack.pop();
	EXPECT_EQ(mstack.getMin(), 1);
	EXPECT_EQ(mstack.top(), 1);
}
开发者ID:babypuma,项目名称:leetcode,代码行数:13,代码来源:min_stack_test.cpp

示例11: main

int main() {
	MinStack m;
	m.push(3);
	m.push(2);
	m.push(1);
	cout << m.getMin() << endl;
	m.pop();
	cout << m.getMin() << endl;
	m.pop();
	cout << m.getMin() << endl;
	m.pop();

}
开发者ID:xingkungao,项目名称:LeetCode_solutions,代码行数:13,代码来源:min_stack.cpp

示例12: main

int main(){
  MinStack stk;
  stk.push(3);
  stk.push(1);
  stk.push(8);
  int minS = stk.getMin();
  stk.push(7);
  stk.pop();
  stk.pop();
  stk.push(12);
  minS = stk.getMin();
  getchar();
  return 0;
}
开发者ID:JimberXin,项目名称:Leetcode,代码行数:14,代码来源:Min+Stack.cpp

示例13: main

int main () {
	MinStack st;
	st.push(2);st.push(0);st.push(3);
	st.push(1);
	cout << st.top() << endl;
	cout << st.getMin();
}
开发者ID:guohuiGH,项目名称:codes,代码行数:7,代码来源:155_min_stack.cpp

示例14: main

int main()
{
    MinStack ms;
    ms.push(2);
    ms.push(0);
    ms.push(3);
    ms.push(0);
    cout << ms.getMin() << endl;
    ms.pop();
    cout << ms.getMin() << endl;
    ms.pop();
    cout << ms.getMin() << endl;
    ms.pop();
    cout << ms.getMin() << endl;
    return 0;
}
开发者ID:python27,项目名称:AlgorithmSolution,代码行数:16,代码来源:MinStack.cpp

示例15: main

int main()
{
	int result;
	MinStack s;
	s.push(-10000);
	s.push(-9999);
	s.push(-9998);
	s.push(-9997);
	s.push(-9996);
	s.push(-9995);
	s.push(-9994);
	s.push(-9993);
	s.push(-9992);
	s.push(-9991);
	s.push(-9990);
	s.show();
	
	result = s.getMin();
	cout << "the getMin result = " << result << endl;
	
	result = s.top();
	cout << "the top result = " << result << endl;

	s.pop();
	s.show();
	return 0;
}
开发者ID:zwy001,项目名称:leetcode,代码行数:27,代码来源:min_vectorstack.cpp


注:本文中的MinStack::getMin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。