国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

棧和隊列(一)

2019-11-08 01:56:05
字體:
來源:轉載
供稿:網友

找出最小值

public class sAD01 { PRivate Stack<Integer> Data; private Stack<Integer> Min; public sAD01(){ this.Data = new Stack<Integer>(); this.Min = new Stack<Integer>(); } public void push(int newNum){ if(this.Min.isEmpty()){ this.Min.push(newNum); } else if(newNum <= this.getMin()){ this.Min.push(newNum); } this.Data.push(newNum); } public int pop(){ if(this.Data.isEmpty()){ throw new RuntimeException("your stack is empty"); } int value = this.Data.pop(); if(value == this.getMin()){ this.Min.pop(); } return value; } public int getMin(){ if(this.Min.isEmpty()){ throw new RuntimeException("your stack is empty"); } return this.Min.peek(); }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永泰县| 介休市| 水富县| 来宾市| 宝鸡市| 长岛县| 科技| 青岛市| 成都市| 鄯善县| 台东市| 历史| 青海省| 金门县| 黄冈市| 萍乡市| 阳泉市| 吴桥县| 平凉市| 抚宁县| 论坛| 滨海县| 犍为县| 若羌县| 桦川县| 新干县| 平度市| 锡林浩特市| 鄂州市| 南岸区| 嘉禾县| 沁水县| 五峰| 永善县| 天台县| 安岳县| 洱源县| 西和县| 汾阳市| 调兵山市| 东至县|