『力扣刷题』232_用栈实现队列 解题代码


html:
embed_local_images: true
embed_svg: true
offline: true
toc: undefined

print_background: false
export_on_save:
html: false
date: 2019-09-08
updated: 2019-09-08
categories: 力扣刷题
title: 『力扣刷题』232_用栈实现队列 解题代码
tags: 队列 栈 代码
layout: post
cover: ‘’
subtitle: subtitle

  • content
    {:toc}

LeetCode-cn 力扣刷题

LeetCode-cn力扣刷题目录

232_用栈实现队列

使用队列实现栈的下列操作:
push(x) – 元素 x 入栈
pop() – 移除栈顶元素
top() – 获取栈顶元素
empty() – 返回栈是否为空
注意:
你只能使用队列的基本操作-- 也就是 push to back, peek/pop from front, size, 和 is empty 这些操作是合法的。
你所使用的语言也许不支持队列。 你可以使用 list 或者 deque(双端队列)来模拟一个队列 , 只要是标准的队列操作即可。
你可以假设所有操作都是有效的(例如, 对一个空的栈不会调用 pop 或者 top 操作)。

『力扣刷题』232_用栈实现队列 解题代码


/**
 * Your MyQueueStack object will be instantiated and called as such:
 * MyQueueStack obj = new MyQueueStack();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.top();
 * boolean param_4 = obj.empty();
 */

下载地址见文末

支持原创

码文不易,希望支持,谢谢->支持原创

微信支付微信支付

扫个红包
[外链图片转存失败(img-yT9zqeqS-1569418777569)(https://raw.githubusercontent.com/923132714/my_picture/master/blog/support/扫码领红包.png “扫码领红包”)]

[外链图片转存失败(img-723wuQfW-1569418777570)(https://github.com/923132714/my_picture/blob/master/blog/support/%E7%A6%8F%E5%88%A9.png?raw=true “福利”)]

上面这张图,请各位理智对待(分享收益不足望大家谅解)

再次感谢,大家对本人的支持。

代码下载

232_用栈实现队列 代码下载

232_用栈实现队列 代码下载

232_用栈实现队列 代码下载

解压密码:qq923132714

题目来源:力扣(LeetCode)
题目链接:https://leetcode-cn.com/problems/implement-stack-using-queues

你可能感兴趣的:(力扣,数据结构,算法,力扣,leetcode,刷题,编程,代码)