Min Stack
来源:互联网 发布:淘宝卡 哪个好 编辑:程序博客网 时间:2024/05/23 21:03
class MinStack { Node head; public void push(int x) { if (head == null) { head = new Node(x); } else { Node temp = new Node(x); temp.min = Math.min(head.min, x); temp.next = head; head = temp; } } public void pop() { if (head == null) { return; } else { head = head.next; } } public int top() { if (head == null) { return Integer.MAX_VALUE; } else { return head.value; } } public int getMin() { if (head == null) { return Integer.MAX_VALUE; } else { return head.min; } }}class Node { int value; int min; Node next; Node(int x) { value = x; min = x; next = null; }}
0 0
- min stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- Min Stack
- POJ 2079 Triangle(凸包-旋转卡壳)
- 加速c++输入
- AsyncHttpClient, RequestParams ,AsyncHttpResponseHandler三个类使用方法
- 关于 No Spring WebApplicationInitializer types detected on classpath卡死的解决办法
- CSS3——gradient渐变
- Min Stack
- Java 日志缓存机制的实现
- Java基础之代理模式
- uploadify(jquery)插件的使用及图片上传预览
- linux 常用命令
- yum源配置
- cin.tie(NULL)--加速
- 应用系统之间数据传输的几种方式
- Java 语言中 Enum 类型的使用介绍