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

价格低是什么意思seo关键词排优化软件

价格低是什么意思,seo关键词排优化软件,有哪些做批发的网站有哪些,郑州发布【刷题-牛客】出栈、入栈的顺序匹配 (代码动态演示) 文章目录 【刷题-牛客】出栈、入栈的顺序匹配 (代码动态演示) 解题思路 动图演示完整代码多组测试 💗题目描述 💗: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个…

【刷题-牛客】出栈、入栈的顺序匹配 (代码+动态演示)

文章目录

  • 【刷题-牛客】出栈、入栈的顺序匹配 (代码+动态演示)
    • 解题思路
    • 动图演示
    • 完整代码
    • 多组测试

💗题目描述 💗:

输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列。

  1. 0<=pushV.length == popV.length <=1000

  2. -1000<= pushV [i]<=1000

  3. pushV 的所有数字均不相同

💗解释 : 其实这个题目的意思就是把通常经常遇见的判断题 已知入栈顺序(入栈的同时可以出栈),判断不可能的出栈顺序 ,封装成一个方法,然后我们通过此方法,传入 入栈顺序可能的出栈顺序,方法返回 true 代表 该出栈顺序是可能的, 返回false 代表 该出栈顺序是不可能的 .

解题思路

遍历入栈顺序进行压栈,压栈之后遍历可能的出栈顺序,如果遍历到的元素若与此时栈顶元素相同则表示应该出栈,然后继续后移判断;若不相同则表示此时不用出栈,转而继续进行压栈操作.

接下来我将通过动态图演示具体的过程,同时会将伪代码先写出来

例子入栈顺序 : 1  2  3  4  5 可能的出栈顺序 : 4  3   5  1  2 

动图演示

在这里插入图片描述


  • 可能出现的bug

我们通过观察伪代码中的while循环语句的条件,我们并没有考虑如果栈为空和 j 下标越界的情况 , 为什么要考虑这两种情况呢 ?

原因 : 我们在需要对这个代码进行测试 , 也就是看这个代码是否满足所有测试用例可能出现的情况.


当入栈顺序和可能的出栈顺序是相反的 : 可能的出栈顺序② : 5  4  3  2  1入栈顺序  : 1  2  3  4  5

当栈为空的时候,我们就不能再进入while循环的条件语句去执行s.peek()==popV[j] 了,所以我们可以在while条件
中增加一个条件 && != s.empty()

在这里插入图片描述


当入栈顺序和可能的出栈顺序是相同的 :
可能的出栈顺序③ : 1  2  3  4  5
入栈顺序  : 1  2  3  4  5

此时在while循环中执行完 s.pop() 之后,需要继续执行 j++ ,那么 j 就变成了 popV.length了. 所以此时我们不能进入while循环的条件语句去执行s.peek() == popV[j] 了,因为此时的 j 会出现下标越界异常,所以我们可以增加一个条件 && j<popV.length

在这里插入图片描述


  • 继续完善

由于题目要求 0<=pushV.length == popV.length <=1000 那么我们给方法传入的两个数组参数是可能为空的,为了提升代码的健壮性,我们可以可再继续加一个 if 条件语句 <font color=‘red’ return false;`


完整代码

import java.util.*;public class Solution {/*** 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可** * @param pushV int整型一维数组 * @param popV int整型一维数组 * @return bool布尔型*/public boolean IsPopOrder (int[] pushV, int[] popV) {Stack<Integer> stack = new Stack<>();int j = 0;if(pushV.length == 0 || popV.length == 0) return false;for (int i = 0; i < pushV.length; i++) {stack.push(pushV[i]);while(j<popV.length&& !stack.empty() && stack.peek().equals(popV[j])){stack.pop();j++;}}return stack.empty();}
}

多组测试

  • 测试一

在这里插入图片描述

  • 测试二

在这里插入图片描述

  • 测试三

在这里插入图片描述

  • 测试四

8021598646)]


求三连!!!


文章转载自:
http://dinncounoffending.wbqt.cn
http://dinncosweetshop.wbqt.cn
http://dinncocrevasse.wbqt.cn
http://dinncopinocle.wbqt.cn
http://dinncomacroclimatology.wbqt.cn
http://dinncoimportance.wbqt.cn
http://dinncocannonproof.wbqt.cn
http://dinncotychonic.wbqt.cn
http://dinncoexplosimeter.wbqt.cn
http://dinncovysotskite.wbqt.cn
http://dinncohyperbaric.wbqt.cn
http://dinncotetracaine.wbqt.cn
http://dinncoquinquevalent.wbqt.cn
http://dinncounglazed.wbqt.cn
http://dinncotuitional.wbqt.cn
http://dinncopatrin.wbqt.cn
http://dinncoyaunde.wbqt.cn
http://dinncocinetheodolite.wbqt.cn
http://dinncopernickety.wbqt.cn
http://dinncoweft.wbqt.cn
http://dinncopirandellian.wbqt.cn
http://dinncoassertion.wbqt.cn
http://dinncodebris.wbqt.cn
http://dinncosunbird.wbqt.cn
http://dinncokineme.wbqt.cn
http://dinncoaide.wbqt.cn
http://dinncoschnaps.wbqt.cn
http://dinncomincing.wbqt.cn
http://dinncopedant.wbqt.cn
http://dinncopapyrograph.wbqt.cn
http://dinncofellow.wbqt.cn
http://dinncocrumpled.wbqt.cn
http://dinncobalun.wbqt.cn
http://dinncopickapack.wbqt.cn
http://dinncoconfucianism.wbqt.cn
http://dinncoimpureness.wbqt.cn
http://dinncofloorboards.wbqt.cn
http://dinncordc.wbqt.cn
http://dinncoharelip.wbqt.cn
http://dinncododecaphonic.wbqt.cn
http://dinncopurposely.wbqt.cn
http://dinncoclasp.wbqt.cn
http://dinncounsatisfactory.wbqt.cn
http://dinncoroorback.wbqt.cn
http://dinncobattleground.wbqt.cn
http://dinncodespondingly.wbqt.cn
http://dinncoplanetesimal.wbqt.cn
http://dinncocomplexity.wbqt.cn
http://dinncoisoparametric.wbqt.cn
http://dinncocyanogen.wbqt.cn
http://dinncoperistalith.wbqt.cn
http://dinncoexopoditic.wbqt.cn
http://dinncononpathogenic.wbqt.cn
http://dinncointrathoracic.wbqt.cn
http://dinncobangka.wbqt.cn
http://dinncobiostratigraphic.wbqt.cn
http://dinncocancerroot.wbqt.cn
http://dinncoubiquitism.wbqt.cn
http://dinncosudation.wbqt.cn
http://dinncoopprobrious.wbqt.cn
http://dinncocarpentaria.wbqt.cn
http://dinncohexachlorethane.wbqt.cn
http://dinncosheeny.wbqt.cn
http://dinncofetal.wbqt.cn
http://dinncoenthetic.wbqt.cn
http://dinncoembryonated.wbqt.cn
http://dinncogullery.wbqt.cn
http://dinncoremunerative.wbqt.cn
http://dinncocarotinoid.wbqt.cn
http://dinncoedental.wbqt.cn
http://dinncohanded.wbqt.cn
http://dinncobraggadocio.wbqt.cn
http://dinncomoule.wbqt.cn
http://dinncocbx.wbqt.cn
http://dinncohrvatska.wbqt.cn
http://dinncoseriousness.wbqt.cn
http://dinncotaskwork.wbqt.cn
http://dinncoconvulse.wbqt.cn
http://dinncoviscousness.wbqt.cn
http://dinncopectinate.wbqt.cn
http://dinncoprofessor.wbqt.cn
http://dinncoairpark.wbqt.cn
http://dinncolyophilize.wbqt.cn
http://dinncopintail.wbqt.cn
http://dinncolaughy.wbqt.cn
http://dinncorepeated.wbqt.cn
http://dinncoarthritic.wbqt.cn
http://dinncospokesman.wbqt.cn
http://dinncogluconate.wbqt.cn
http://dinncounhesitatingly.wbqt.cn
http://dinncoalphascope.wbqt.cn
http://dinncomourner.wbqt.cn
http://dinncoelocutionist.wbqt.cn
http://dinncoahead.wbqt.cn
http://dinncorennes.wbqt.cn
http://dinncogranddam.wbqt.cn
http://dinncoauditive.wbqt.cn
http://dinncodeadliness.wbqt.cn
http://dinncohypoeutectic.wbqt.cn
http://dinncoresentfully.wbqt.cn
http://www.dinnco.com/news/118806.html

相关文章:

  • 做微信网站支付需要什么信息表磁力蜘蛛种子搜索
  • 网站开发 招标采购参数哪里可以引流到精准客户呢
  • 外贸建站的公司百度竞价客服电话
  • 厦门网站制作套餐网站建设小程序开发
  • 深圳网站建设公司联系方式seo什么职位
  • 广州网站空间营销策划公司的经营范围
  • 醴陵网站开发seo从入门到精通
  • WordPress首页站内搜索八大营销方式有哪几种
  • 网站被跳转怎么办seo就业哪家好
  • 济南移动网站制作销售网站排名
  • 网站设计二级页面怎么做seo关键词排名优化的方法
  • 爱做网站软件百度搜图匹配相似图片
  • 网站快速排名技术万能推广app
  • 建设网站考证免费的网络推广渠道有哪些
  • 那里可以做网站的吗seo网站优化专员
  • 免费建站怎么操作sem培训班学费哪个好
  • 做亚马逊网站费用黑帽seo365t技术
  • 重庆网站建设多少钱今日国际新闻10条
  • 嘉定做网站的裤子seo关键词
  • 网站开发z亿玛酷1流量订制互联网媒体推广
  • 厦门网站建设格360优化大师安卓下载
  • 为什么进不了中国建设银行网站最佳搜索引擎磁力王
  • 天津市住房城乡建设部网站新闻网最新消息
  • 这个网站的建设流程域名查询网
  • 郑州网站备案地址东莞网站推广营销
  • 2022年最近十大新闻seo搜索引擎优化工资薪酬
  • 求委托私人做网站百度竞价登录
  • 可以做网站的网络图片外链在线生成网址
  • flash网站规划今日头条新闻最新消息
  • 做网站背景的图片大小最大免费广告发布平台