剑指offer
包含min函数的栈
相似的企业真题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 64M,其他语言128M
热度指数:509567
本题知识点:
栈
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
定义栈的数据结构,请在该类型中实现一个能够得到栈中所含最小元素的min函数(时间复杂度应为O(1))。
上一题
下一题
登录
/
注册
我的提交
编辑器加载中...
import java.util.Stack; public class Solution { public void push(int node) { } public void pop() { } public int top() { } public int min() { } }
class Solution { public: void push(int value) { } void pop() { } int top() { } int min() { } };
# -*- coding:utf-8 -*- class Solution: def push(self, node): # write code here def pop(self): # write code here def top(self): # write code here def min(self): # write code here
class Solution { public void push(int node) { } public void pop() { } public int top() { } public int min() { } }
function push(node) { // write code here } function pop() { // write code here } function top() { // write code here } function min() { // write code here } module.exports = { push : push, pop : pop, top : top, min : min };
function push(node) { // write code here } function pop() { // write code here } function top() { // write code here } function min() { // write code here }
# -*- coding:utf-8 -*- class Solution: def push(self, node): # write code here def pop(self): # write code here def top(self): # write code here def min(self): # write code here
package main func Push(node int) { // write code here } func Pop() { // write code here } func Top() int { // write code here } func Min() int { // write code here }