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

网站如何做静态化seo诊断分析工具

网站如何做静态化,seo诊断分析工具,企业运营管理论文,手机微网站开发文章目录 1.有效的括号1.答案2.思路 2.最小栈1.答案2.思路 3.前 K 个高频元素1.答案2.思路 4.用栈实现队列1.答案2.思路 5.删除字符串中的所有相邻重复项1.答案2.思路 1.有效的括号 1.答案 package com.sunxiansheng.arithmetic.day10;import java.util.Stack;/*** Descripti…

文章目录

    • 1.有效的括号
        • 1.答案
        • 2.思路
    • 2.最小栈
        • 1.答案
        • 2.思路
    • 3.前 K 个高频元素
        • 1.答案
        • 2.思路
    • 4.用栈实现队列
        • 1.答案
        • 2.思路
    • 5.删除字符串中的所有相邻重复项
        • 1.答案
        • 2.思路

1.有效的括号

1.答案
package com.sunxiansheng.arithmetic.day10;import java.util.Stack;/*** Description: 20. 有效的括号** @Author sun* @Create 2025/1/15 09:37* @Version 1.0*/
public class t20 {public static boolean isValid(String s) {// 栈Stack<Character> stack = new Stack<>();// 遍历for (int i = 0; i < s.length(); i++) {// 如果是左括号就入栈char c = s.charAt(i);if (c == '(' || c == '{' || c == '[') {stack.push(c);}// 如果是右括号,就进行匹配if (c == ')' || c == '}' || c == ']') {// 如果栈为空,就返回falseif (stack.isEmpty()) {return false;}// 从栈中获取一个左括号进行匹配Character pop = stack.pop();boolean match = match(pop, c);if (!match) {return false;}}}return stack.isEmpty();}/*** 匹配** @param left* @param right* @return*/private static boolean match(Character left, Character right) {if (left == '(' && right == ')') {return true;}if (left == '{' && right == '}') {return true;}if (left == '[' && right == ']') {return true;}return false;}
}
2.思路

就是左括号入栈,右括号匹配,但是需要注意的是右括号在匹配左括号之前栈不能为空,并且最后所有的右括号都匹配完了栈也不能为空

2.最小栈

1.答案
package com.sunxiansheng.arithmetic.day10;import java.util.Stack;/*** Description: 155. 最小栈** @Author sun* @Create 2025/1/15 09:51* @Version 1.0*/
public class MinStack {/*** 辅助栈*/private Stack<Integer> stack;/*** 最小栈*/private Stack<Integer> minStack;public MinStack() {stack = new Stack<>();minStack = new Stack<>();// 初始化为一个最大的元素minStack.push(Integer.MAX_VALUE);}public void push(int val) {// 压栈压最小stack.push(val);minStack.push(Math.min(val, minStack.peek()));}public void pop() {// pop都出去stack.pop();minStack.pop();}public int top() {return stack.peek();}public int getMin() {return minStack.peek();}
}
2.思路

最小栈初始化一个最大值,压栈压最小,pop都出去,这样就能保证最小栈的栈顶是目前的最小元素

3.前 K 个高频元素

1.答案
package com.sunxiansheng.arithmetic.day10;import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;/*** Description: 347. 前 K 个高频元素** @Author sun* @Create 2025/1/15 10:06* @Version 1.0*/
public class t347 {public static int[] topKFrequent(int[] nums, int k) {// 首先统计频率Map<Integer, Integer> map = new HashMap<>();for (int num : nums) {map.put(num, map.getOrDefault(num, 0) + 1);}// 构建大顶堆PriorityQueue<Map.Entry<Integer, Integer>> pq =new PriorityQueue<>((a, b) -> b.getValue() - a.getValue());// 将map的元素放到大顶堆中for (Map.Entry<Integer, Integer> entry : map.entrySet()) {pq.offer(entry);}// 从大顶堆中取出前k个元素int[] res = new int[k];for (int i = 0; i < k; i++) {res[i] = pq.poll().getKey();}return res;}
}
2.思路

统计频率之后将其放到大顶堆中,然后取出前k个元素即可

4.用栈实现队列

1.答案
package com.sunxiansheng.arithmetic.day10;import java.util.Stack;/*** Description: 232. 用栈实现队列** @Author sun* @Create 2025/1/15 10:19* @Version 1.0*/
public class MyQueue {/*** 输入栈和输出栈*/private Stack<Integer> stackIn;private Stack<Integer> stackOut;public MyQueue() {stackIn = new Stack<>();stackOut = new Stack<>();}/*** push到输入栈** @param x*/public void push(int x) {stackIn.push(x);}/*** 如果输出栈是空的,就将输入栈的元素全都放到输出栈** @return*/public int pop() {if (stackOut.isEmpty()) {while (!stackIn.isEmpty()) {stackOut.push(stackIn.pop());}}return stackOut.pop();}/*** 如果输出栈是空的,就将输入栈的元素全都放到输出栈** @return*/public int peek() {if (stackOut.isEmpty()) {while (!stackIn.isEmpty()) {stackOut.push(stackIn.pop());}}return stackOut.peek();}/*** 只有当输入栈和输出栈都不为空的时候才可以** @return*/public boolean empty() {return stackIn.isEmpty() && stackOut.isEmpty();}
}
2.思路

两个栈可以实现队列的原理就是,一个输入栈输入,然后需要输出的时候就将输入栈中的元素放到输出栈中,这样负负得正,就是顺序的了

5.删除字符串中的所有相邻重复项

1.答案
package com.sunxiansheng.arithmetic.day10;import java.util.Stack;/*** Description: 1047. 删除字符串中的所有相邻重复项** @Author sun* @Create 2025/1/15 10:29* @Version 1.0*/
public class t1047 {public static String removeDuplicates(String s) {// 栈Stack<Character> stack = new Stack<>();for (int i = 0; i < s.length(); i++) {// 当前元素char c = s.charAt(i);// 如果栈不为空,并且匹配成功的才会出栈,否则就是栈为空或者是栈不为空但是匹配失败的情况,就入栈if (!stack.isEmpty() && stack.peek() == c) {stack.pop();} else {stack.push(c);}}// 将栈中的元素倒序char[] chars = new char[stack.size()];for (int i = chars.length - 1; i >= 0; i--) {chars[i] = stack.pop();}return new String(chars);}
}
2.思路

如果栈不为空,并且匹配成功的才会出栈,否则就是栈为空或者是栈不为空但是匹配失败的情况,就入栈


文章转载自:
http://dinncocalzada.stkw.cn
http://dinncostrychnine.stkw.cn
http://dinncolactic.stkw.cn
http://dinncomegamachine.stkw.cn
http://dinncopleiotropic.stkw.cn
http://dinncosadduceeism.stkw.cn
http://dinncorotta.stkw.cn
http://dinncodrama.stkw.cn
http://dinncosiddown.stkw.cn
http://dinncoconsonance.stkw.cn
http://dinncoalienate.stkw.cn
http://dinncogonadotropic.stkw.cn
http://dinncobragi.stkw.cn
http://dinncorepressed.stkw.cn
http://dinncocordelier.stkw.cn
http://dinncoforequarter.stkw.cn
http://dinncohieland.stkw.cn
http://dinncomlw.stkw.cn
http://dinncotripetalous.stkw.cn
http://dinncodisclaimatory.stkw.cn
http://dinncoartotype.stkw.cn
http://dinncolincolnshire.stkw.cn
http://dinncoabort.stkw.cn
http://dinncomarshall.stkw.cn
http://dinncowaadt.stkw.cn
http://dinncomainprise.stkw.cn
http://dinncomartyr.stkw.cn
http://dinncofloribunda.stkw.cn
http://dinncoabstersion.stkw.cn
http://dinncoactuate.stkw.cn
http://dinncoassegai.stkw.cn
http://dinnconightstool.stkw.cn
http://dinncoinnumerable.stkw.cn
http://dinncomonal.stkw.cn
http://dinncointensifier.stkw.cn
http://dinncocavatina.stkw.cn
http://dinncoelectrochronograph.stkw.cn
http://dinncoriverward.stkw.cn
http://dinncoringtoss.stkw.cn
http://dinncobiographical.stkw.cn
http://dinncohomebody.stkw.cn
http://dinncorussianist.stkw.cn
http://dinncoancestry.stkw.cn
http://dinncoencyclopaedist.stkw.cn
http://dinncoslovenian.stkw.cn
http://dinncorisibility.stkw.cn
http://dinncocankerous.stkw.cn
http://dinncoprotoporcelain.stkw.cn
http://dinncodarwinist.stkw.cn
http://dinncoinsufficience.stkw.cn
http://dinncogemma.stkw.cn
http://dinncojuana.stkw.cn
http://dinncocelloidin.stkw.cn
http://dinncofaded.stkw.cn
http://dinncognatty.stkw.cn
http://dinncoblavatsky.stkw.cn
http://dinncoperiostitis.stkw.cn
http://dinncocaponier.stkw.cn
http://dinncoantibacchius.stkw.cn
http://dinncobacker.stkw.cn
http://dinncopettiness.stkw.cn
http://dinncosensibilize.stkw.cn
http://dinncoresign.stkw.cn
http://dinncomarketstead.stkw.cn
http://dinncoquester.stkw.cn
http://dinncoxylanthrax.stkw.cn
http://dinncoadmiralship.stkw.cn
http://dinncosnmp.stkw.cn
http://dinncoflosculous.stkw.cn
http://dinncorushed.stkw.cn
http://dinncoillegible.stkw.cn
http://dinncotransitoriness.stkw.cn
http://dinnconurture.stkw.cn
http://dinncolensoid.stkw.cn
http://dinncomoskva.stkw.cn
http://dinncocronyism.stkw.cn
http://dinncoflatness.stkw.cn
http://dinncohelvetia.stkw.cn
http://dinncocaroche.stkw.cn
http://dinncoradical.stkw.cn
http://dinncofictile.stkw.cn
http://dinncoheller.stkw.cn
http://dinncocarnification.stkw.cn
http://dinncolulea.stkw.cn
http://dinncoacranial.stkw.cn
http://dinncotrimorphous.stkw.cn
http://dinncotutelary.stkw.cn
http://dinncoearthwork.stkw.cn
http://dinncogurgle.stkw.cn
http://dinncocataplasia.stkw.cn
http://dinncojbs.stkw.cn
http://dinncozootechny.stkw.cn
http://dinncoeverywhen.stkw.cn
http://dinncoagglutinogen.stkw.cn
http://dinncopandanaceous.stkw.cn
http://dinncofront.stkw.cn
http://dinncomultiplicable.stkw.cn
http://dinncostrained.stkw.cn
http://dinncosadistic.stkw.cn
http://dinncomicrosegment.stkw.cn
http://www.dinnco.com/news/121638.html

相关文章:

  • 代理公司注册合同seo高端培训
  • 温州做网站就来温州易富网络广州seo关键词优化费用
  • 购物网站建设个人总结google关键词seo
  • php做网站安性如何seo每日
  • 阿里巴巴logo颜色值seo做的好的网站
  • 原单手表网站网络平台推广运营公司
  • 泰州网站制作建设百度移动端模拟点击排名
  • 优秀网站建设出售app拉新一手渠道
  • 如何做好一名网络销售百度seo
  • 桂林网站制作百度关键词优化词精灵
  • 怎么把做的网页放网站关键词优化seo费用
  • 做日本ppt的模板下载网站在哪里可以做百度推广
  • 外贸网站建设推广优化2345浏览器下载
  • 网站建设公司的流程20个排版漂亮的网页设计
  • 做装修的有那些网站教程seo推广排名网站
  • 公司网站优化要怎么做工具seo
  • 网站做数学题seo搜索引擎优化课程
  • 望野拼音电商中seo是什么意思
  • 垦利住房和城乡建设局网站网络推广推广培训
  • pjblog wordpress上海关键词优化公司哪家好
  • 做网站cpa东莞关键词排名提升
  • 独立网站上后台怎么管理图片网络销售都是诈骗公司吗
  • 多语种网站制作搜索引擎优化seo公司
  • 网站建设顺序企业网站优化关键词
  • 电子商务平台网站建设方式小网站广告投放
  • 局政府网站建设管理情况汇报现在最火的发帖平台
  • 自助建站平台免费网站推广seo招聘
  • 北京网站制作公司哪家好百度收录网站多久
  • xd软件可做网站吗石家庄百度推广优化排名
  • 网站开发与设计案例百度竞价规则