当前位置: 首页 > news >正文

网站建设企业熊掌号wordpress自带分页函数

网站建设企业熊掌号,wordpress自带分页函数,做外贸网站那个平台好,哈尔滨门户网站建站232. 用栈实现队列 已解答 简单 相关标签 相关企业 请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作(push、pop、peek、empty): 实现 MyQueue 类: void push(int x) 将元素 x 推到队列的末尾int pop() 从队…

232. 用栈实现队列

已解答

简单

相关标签

相关企业

请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作(pushpoppeekempty):

实现 MyQueue 类:

  • void push(int x) 将元素 x 推到队列的末尾
  • int pop() 从队列的开头移除并返回元素
  • int peek() 返回队列开头的元素
  • boolean empty() 如果队列为空,返回 true ;否则,返回 false

说明:

  • 你 只能 使用标准的栈操作 —— 也就是只有 push to toppeek/pop from topsize, 和 is empty 操作是合法的。
  • 你所使用的语言也许不支持栈。你可以使用 list 或者 deque(双端队列)来模拟一个栈,只要是标准的栈操作即可。

示例 1:

输入:
["MyQueue", "push", "push", "peek", "pop", "empty"]
[[], [1], [2], [], [], []]
输出:
[null, null, null, 1, 1, false]解释:
MyQueue myQueue = new MyQueue();
myQueue.push(1); // queue is: [1]
myQueue.push(2); // queue is: [1, 2] (leftmost is front of the queue)
myQueue.peek(); // return 1
myQueue.pop(); // return 1, queue is [2]
myQueue.empty(); // return false

链表

35min

链表的基本操作

遍历的时候需要用指针

class ListNode {int val;ListNode next;ListNode() {}  // 默认构造函数ListNode(int x) {val = x;next = null;}ListNode(int val, ListNode next) {this.val = val; this.next = next; }
}
class MyQueue {ListNode head;public MyQueue() {this.head = null;}public void push(int x) {ListNode newNode = new ListNode(x);if (head == null) {head = newNode; // 如果链表为空,直接设置头节点} else {// 遍历到链表末尾ListNode current = head;while (current.next != null) {current = current.next; // 遍历到链表末尾}current.next = newNode; // 将新节点添加到尾部}}public int pop() {ListNode current = head;if(current == null) {return -1;}else{int valValue = head.val;head = head.next;return valValue;}}public int peek() {return this.head.val;}public boolean empty() {return head == null; // 检查队列是否为空}
}

http://www.yayakq.cn/news/627962/

相关文章:

  • 戴尔公司网站建设的特点是什么网站建设的公司收费标准
  • 做电子商务网站的总结岳阳市建设局网站
  • 广州优质网站排名公司网站设计前沿网站
  • 网站建设公司广告网站建设文化效果
  • 教做甜品网站空壳公司怎么注册
  • 北京做网站开发公司有哪些网络营销策划名词解释
  • 网页网站学做网站需要多长时间
  • 专业的南昌网站建设天津做网站优化价格
  • 毕业设计的网站网站模板 站长之家
  • 手机网站全屏代码深圳展览设计网站建设
  • 陕西开龄建设网站工业互联网平台分类
  • 双鱼儿 网站建设购物网站设计的目的
  • 响应式网站用什么语言网站怎么建
  • 重庆wordpress网站建设汕头房产网站建设
  • 石景山青岛网站建设背景wordpress
  • 网站开发与兼容模式网站建设哪家好 万维科技
  • 美丽乡村建设网站wordpress代码逻辑
  • 凯里市经济开发区建设局网站网页界面设计艺术教程
  • 有没有好网站推荐郑州seo培训班
  • html在网站开发中的应用广东汇鑫科技网站建设
  • 百度商桥置入网站网站开发技术选择
  • 网站突然掉排名seo免费培训
  • 这么给网站做关键字比较有设计感的网站
  • 男的做直播网站好企业网站模板专业网
  • 手机网站域名m打头微信网名
  • 建设网站需要哪些元素凡科做网站类型应该做哪个
  • 网站开发策划方案做企业网站排名优化要多少钱
  • 网站挂马教程动漫制作专业电脑配置
  • 网站建设与品牌策划方案报价网页制作专业软件
  • 做网站的公司销售话术常州市建设工程质监站网站