Implement a stack with min() function, which will return the smallest number in the stack.
It should support push, pop and min operation all in O(1) cost.
1.
用map记录所有值和出现的次数,根据map有序的特征取出最小值
2.
维护一个存放每阶段最小值的栈
这个代码就很简洁,推荐
mb63887cf57331d ©著作权
Implement a stack with min() function, which will return the smallest number in the stack.
It should support push, pop and min operation all in O(1) cost.
用map记录所有值和出现的次数,根据map有序的特征取出最小值
维护一个存放每阶段最小值的栈
这个代码就很简洁,推荐
kube-prometheus-stack 小试牛刀
1.变量与赋值1.1变量name="xiaofeng" <==注:等号前面的name是变量;如果等号后面没有加引号,会认为xiaofeng是变量;加引号是字符串。age=21print (name,age) <==调用两个变量,中间用逗号。例1name=input("print input your name: ")print
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M