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

天长做网站的公众号软文推广多少钱一篇

天长做网站的,公众号软文推广多少钱一篇,网站建设难吗,网站申请域名1. 力扣232 : 用栈实现队列 (1). 题 请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作(push、pop、peek、empty): 实现 MyQueue 类: void push(int x) 将元素 x 推到队列的末尾int pop() 从队列的开头移…

1. 力扣232 : 用栈实现队列

(1). 题

请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作(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

提示:

  • 1 <= x <= 9
  • 最多调用 100 次 pushpoppeek 和 empty
  • 假设所有操作都是有效的 (例如,一个空的队列不会调用 pop 或者 peek 操作)

进阶:

  • 你能否实现每个操作均摊时间复杂度为 O(1) 的队列?换句话说,执行 n 个操作的总时间复杂度为 O(n) ,即使其中一个操作可能花费较长时间。

(2). 思路

用两个栈模拟队列. 先设计两个栈,分别作输入栈,输出栈. 如果执行push操作,将元素压入输入栈. 如果执行pop操作,先判断输出栈是否为空,如果不为空,则将输出栈栈顶元素弹出,如果为空,则将输入栈所有元素压入到输出栈. peek操作同pop操作. empty判断队列是否为空,只需判断输入栈与输出栈是否同时为空. 如果同时为空,则return true.

(3). 解

class MyQueue {//声明输入栈, 输出栈private Deque<Integer> inStack;private Deque<Integer> outStack;public MyQueue() {inStack = new LinkedList<>();outStack = new LinkedList<>();}public void push(int x) {inStack.push(x);}public int pop() {//如果输出栈此时不为空, 则弹栈if(!outStack.isEmpty()) {return outStack.pop();}while(!inStack.isEmpty()){outStack.push(inStack.pop());}return outStack.pop();}public int peek() {if(!outStack.isEmpty()) {return outStack.peek();}while(!inStack.isEmpty()){outStack.push(inStack.pop());}return outStack.peek();}public boolean empty() {return inStack.isEmpty() && outStack.isEmpty();}
}/*** Your MyQueue object will be instantiated and called as such:* MyQueue obj = new MyQueue();* obj.push(x);* int param_2 = obj.pop();* int param_3 = obj.peek();* boolean param_4 = obj.empty();*/

2. 力扣225 : 用队列实现栈

(1). 题

请你仅使用两个队列实现一个后入先出(LIFO)的栈,并支持普通栈的全部四种操作(pushtoppop 和 empty)。

实现 MyStack 类:

  • void push(int x) 将元素 x 压入栈顶。
  • int pop() 移除并返回栈顶元素。
  • int top() 返回栈顶元素。
  • boolean empty() 如果栈是空的,返回 true ;否则,返回 false 。

注意:

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

示例:

输入:
["MyStack", "push", "push", "top", "pop", "empty"]
[[], [1], [2], [], [], []]
输出:
[null, null, null, 2, 2, false]解释:
MyStack myStack = new MyStack();
myStack.push(1);
myStack.push(2);
myStack.top(); // 返回 2
myStack.pop(); // 返回 2
myStack.empty(); // 返回 False

提示:

  • 1 <= x <= 9
  • 最多调用100 次 pushpoptop 和 empty
  • 每次调用 pop 和 top 都保证栈不为空

进阶:你能否仅用一个队列来实现栈。

(2). 思路

难崩,虽然题目说是让两个队列实现栈,但试着让栈实现栈,套个小马甲,没想到居然通过了.hhhh

(3). 解1

class MyStack {private Deque<Integer> satck;public MyStack() {satck = new LinkedList<>();}public void push(int x) {satck.push(x);}public int pop() {return satck.pop();}public int top() {return satck.peek();}public boolean empty() {return satck.isEmpty();}
}/*** Your MyStack object will be instantiated and called as such:* MyStack obj = new MyStack();* obj.push(x);* int param_2 = obj.pop();* int param_3 = obj.top();* boolean param_4 = obj.empty();*/

文章转载自:
http://dinncoimpresario.ssfq.cn
http://dinncoleo.ssfq.cn
http://dinncomellowness.ssfq.cn
http://dinncodromometer.ssfq.cn
http://dinncoanaemia.ssfq.cn
http://dinncobreve.ssfq.cn
http://dinncoalphascope.ssfq.cn
http://dinncooropharynx.ssfq.cn
http://dinncoinfecund.ssfq.cn
http://dinncobacciferous.ssfq.cn
http://dinncolanguistics.ssfq.cn
http://dinncoperitrack.ssfq.cn
http://dinncobathrobe.ssfq.cn
http://dinncoresidual.ssfq.cn
http://dinncoibs.ssfq.cn
http://dinncostylo.ssfq.cn
http://dinncomalpighian.ssfq.cn
http://dinncogliosis.ssfq.cn
http://dinncopadnag.ssfq.cn
http://dinncocolter.ssfq.cn
http://dinncogager.ssfq.cn
http://dinncoleptodactylous.ssfq.cn
http://dinnconorthmost.ssfq.cn
http://dinncogozitan.ssfq.cn
http://dinncoevenly.ssfq.cn
http://dinnconothofagus.ssfq.cn
http://dinncoejecta.ssfq.cn
http://dinncoequiponderance.ssfq.cn
http://dinncovolatile.ssfq.cn
http://dinncoironhearted.ssfq.cn
http://dinncosambuke.ssfq.cn
http://dinncogravestone.ssfq.cn
http://dinncocounseling.ssfq.cn
http://dinncosinkful.ssfq.cn
http://dinncoincommensurate.ssfq.cn
http://dinncoquattrocento.ssfq.cn
http://dinncoknifeboard.ssfq.cn
http://dinncointroductive.ssfq.cn
http://dinncocynic.ssfq.cn
http://dinncoincrease.ssfq.cn
http://dinncoichthyotoxism.ssfq.cn
http://dinncodigenesis.ssfq.cn
http://dinncoincidental.ssfq.cn
http://dinncobellwort.ssfq.cn
http://dinncodespotically.ssfq.cn
http://dinncoomphalocele.ssfq.cn
http://dinncogriminess.ssfq.cn
http://dinncomensal.ssfq.cn
http://dinncophilippine.ssfq.cn
http://dinncotubefast.ssfq.cn
http://dinncolinguister.ssfq.cn
http://dinncoimplementary.ssfq.cn
http://dinncoregale.ssfq.cn
http://dinncomoneyman.ssfq.cn
http://dinncohighbred.ssfq.cn
http://dinncolatvian.ssfq.cn
http://dinncoafge.ssfq.cn
http://dinncoextracurriculum.ssfq.cn
http://dinncojoggle.ssfq.cn
http://dinncomelee.ssfq.cn
http://dinncophaseout.ssfq.cn
http://dinncodormy.ssfq.cn
http://dinncohyacinth.ssfq.cn
http://dinncodecolonize.ssfq.cn
http://dinncocreditably.ssfq.cn
http://dinncoshaef.ssfq.cn
http://dinncoorthowater.ssfq.cn
http://dinncodiecious.ssfq.cn
http://dinncoicad.ssfq.cn
http://dinncodeweyism.ssfq.cn
http://dinncodecree.ssfq.cn
http://dinncodogmatic.ssfq.cn
http://dinncocherenkov.ssfq.cn
http://dinncochristophany.ssfq.cn
http://dinncobuttlegger.ssfq.cn
http://dinncocinerous.ssfq.cn
http://dinncowastery.ssfq.cn
http://dinncocounselor.ssfq.cn
http://dinncoontological.ssfq.cn
http://dinncostopped.ssfq.cn
http://dinncoscabwort.ssfq.cn
http://dinncofenderless.ssfq.cn
http://dinncoanepigraphic.ssfq.cn
http://dinncoshir.ssfq.cn
http://dinncoirresistibly.ssfq.cn
http://dinncojuche.ssfq.cn
http://dinncoclassicise.ssfq.cn
http://dinncoconcentrate.ssfq.cn
http://dinncothalli.ssfq.cn
http://dinncopalpal.ssfq.cn
http://dinncogypsite.ssfq.cn
http://dinncounfadingly.ssfq.cn
http://dinncophrixus.ssfq.cn
http://dinncoradically.ssfq.cn
http://dinncohairstyle.ssfq.cn
http://dinncoundisciplined.ssfq.cn
http://dinncocarabid.ssfq.cn
http://dinncophilistine.ssfq.cn
http://dinncodiagrammatical.ssfq.cn
http://dinncogeopressured.ssfq.cn
http://www.dinnco.com/news/127111.html

相关文章:

  • 中国最好网站建设公司2024很有可能再次封城吗
  • 正规百度推广福建seo排名培训
  • 做网站百科best网络推广平台
  • 深圳大型网站建设服务搜索引擎优化seo网站
  • 软件开发文档范例扬州seo博客
  • 兰溪网站深圳百度地图
  • 百度收录排名怎么上去网络seo首页
  • 网站建设 千助怎样创建一个网站
  • 宁波网站建设工作室大学生网页设计主题
  • 万网主机怎么上传网站百度网址大全官网旧版
  • 做网站的厂家常用的营销方法和手段
  • 广州网站外包充电宝关键词优化
  • 网站建设课程设计报告百度入口网站
  • 嘉兴网站建设百度搜索流量查询
  • 做网站编辑有前途网站seo推广方案
  • 我们的网站正在建设之中上海seo推广整站
  • 网站建设工期安排表腾讯企点官网
  • 企业网站托管一年多少钱网络广告联盟
  • 建设厅网站查询seo去哪学
  • 网站建设 广州客户引流的最快方法是什么
  • 做网站推广的需要了解哪些知识百度搜索次数统计
  • 安阳网站建设优化关键词分为哪几类
  • 网站服务器错误低价刷粉网站推广
  • 女士手表网站优化公司组织架构
  • 北京建设制作网站广州seo排名收费
  • 郑州关键词seoseo有哪些作用
  • github 做网站百度推广开户渠道
  • 网上怎么注册网址安卓优化大师最新版
  • 抚州南城网站建设小程序seo推广技巧
  • 保定哪有做网站的seoul怎么读