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

怎样做网站banner网址收录入口

怎样做网站banner,网址收录入口,2019做网站赚钱么,北京公司招聘力扣爆刷第153天之TOP100五连刷26-30(接雨水、环形链表、最长上升子序列) 文章目录 力扣爆刷第153天之TOP100五连刷26-30(接雨水、环形链表、最长上升子序列)一、300. 最长递增子序列二、415. 字符串相加三、143. 重排链表四、42.…

力扣爆刷第153天之TOP100五连刷26-30(接雨水、环形链表、最长上升子序列)

文章目录

      • 力扣爆刷第153天之TOP100五连刷26-30(接雨水、环形链表、最长上升子序列)
      • 一、300. 最长递增子序列
      • 二、415. 字符串相加
      • 三、143. 重排链表
      • 四、42. 接雨水
      • 五、142. 环形链表 II

一、300. 最长递增子序列

题目链接:https://leetcode.cn/problems/longest-increasing-subsequence/description/
思路:求最长递增子序列,典型的动态规划题,定义dp数组表示,dp[i]为以nums[i]为结尾的区间中的最长递增子序列。那么对于dp[i]来说,区间中的每一个元素都有可能是最长递增子序列的一部分,对于每一个区间,从千往后遍历寻找。

class Solution {public int lengthOfLIS(int[] nums) {int[] dp = new int[nums.length];Arrays.fill(dp, 1);int max = 1;for(int i = 1; i < nums.length; i++) {for(int j = 0; j < i; j++) {if(nums[j] < nums[i]) {dp[i] = Math.max(dp[i], dp[j]+1);}}max = Math.max(dp[i], max);}return max;}
}

二、415. 字符串相加

题目链接:https://leetcode.cn/problems/add-strings/description/
思路:字符串相加这也是非常经典的题目,主要是边界条件的控制,利用 || 或条件不全为0的情况下,不会推出循环,来完成不等长字符串的相加,以及进位的相加。注意使用stringbuilder,添加完成后翻转。

class Solution {public String addStrings(String num1, String num2) {int i = num1.length() - 1, j = num2.length() - 1;int res = 0;StringBuilder sb = new StringBuilder();while(i >= 0 || j >= 0 || res != 0) {int a = i >= 0 ? num1.charAt(i) - '0' : 0;int b = j >= 0 ? num2.charAt(j) - '0' : 0;int sum = res + a + b;res = sum / 10;sb.append(sum % 10);i--;j--;}return sb.reverse().toString();}
}

三、143. 重排链表

题目链接:https://leetcode.cn/problems/reorder-list/description/
思路:题目要求如下重排,其实很简单,只需要找到链表中点,然后把中点后面的节点翻转,然后再逐个拼接。
如1 2 3 4 5,中点3, 后面翻转 5 4 ,然后得到了两个链表,1 2 3和 5 4 ,然后逐一拼接即可得到1 5 2 4 3.
在这里插入图片描述

在这里插入图片描述

/*** Definition for singly-linked list.* public class ListNode {*     int val;*     ListNode next;*     ListNode() {}*     ListNode(int val) { this.val = val; }*     ListNode(int val, ListNode next) { this.val = val; this.next = next; }* }*/
class Solution {public void reorderList(ListNode head) {ListNode root = new ListNode(-1, head);ListNode slow = root, fast = root;while(fast != null && fast.next != null) {slow = slow.next;fast = fast.next.next;}ListNode p = slow.next, pre = null;slow.next = null;while(p != null) {pre = p.next;p.next = slow.next;slow.next = p;p = pre;}fast = slow.next;slow.next = null;slow = head;while(fast != null) {ListNode t1 = slow.next;ListNode t2 = fast.next;slow.next = fast;fast.next = t1;slow = t1;fast = t2;}}
}

四、42. 接雨水

题目链接:https://leetcode.cn/problems/trapping-rain-water/description/
思路:接雨水,单调栈。只需要用单调栈构建出来一个凹槽即可,即当前元素小于等于栈顶元素即入栈,大于栈顶元素则出栈,出栈出来的就是凹槽的底部,当前元素是凹槽的右边,现在的栈顶是凹槽的左边,这样就可以计算凹槽的长和宽,进行面积计算。

class Solution {public int trap(int[] height) {LinkedList<Integer> stack = new LinkedList<>();int sum = 0;for(int i = 0; i < height.length; i++) {while(!stack.isEmpty() && height[i] > height[stack.peek()]) {int mid = height[stack.pop()];if(!stack.isEmpty()) {int w = i - stack.peek() - 1;int h = Math.min(height[i], height[stack.peek()]) - mid;sum += w * h;}}stack.push(i);}return sum;}
}

五、142. 环形链表 II

题目链接:https://leetcode.cn/problems/linked-list-cycle-ii/description/
思路:求环形链表的入口也是一道经典的题目,快慢指针如果相遇则说明有环,然后两个指针一个从头结点出发,一个从相遇节点出发,再次相遇,即为环的入口。

public class Solution {public ListNode detectCycle(ListNode head) {ListNode slow = head, fast = head;while(fast != null && fast.next != null) {slow = slow.next;fast = fast.next.next;if(slow == fast) break;}if(fast == null || fast.next == null) return null;fast = slow;slow = head;while(fast != slow) {slow = slow.next;fast = fast.next;}return slow;}
}

文章转载自:
http://dinncochoirboy.bkqw.cn
http://dinncomob.bkqw.cn
http://dinncomcat.bkqw.cn
http://dinncoreticulosis.bkqw.cn
http://dinncouddered.bkqw.cn
http://dinncohyoscyamin.bkqw.cn
http://dinncoinexistent.bkqw.cn
http://dinncounsaturate.bkqw.cn
http://dinncosignifiable.bkqw.cn
http://dinncoequably.bkqw.cn
http://dinncoinformal.bkqw.cn
http://dinncorow.bkqw.cn
http://dinncounsworn.bkqw.cn
http://dinncopeenge.bkqw.cn
http://dinncodopaminergic.bkqw.cn
http://dinncounweave.bkqw.cn
http://dinnconuminosum.bkqw.cn
http://dinncopulsion.bkqw.cn
http://dinncoargentine.bkqw.cn
http://dinncosubschema.bkqw.cn
http://dinncobanter.bkqw.cn
http://dinncobranchiopod.bkqw.cn
http://dinncopredicatively.bkqw.cn
http://dinncopreaseptic.bkqw.cn
http://dinncoanthill.bkqw.cn
http://dinncoabominator.bkqw.cn
http://dinncochiropter.bkqw.cn
http://dinnconite.bkqw.cn
http://dinncolabourwallah.bkqw.cn
http://dinncoprexy.bkqw.cn
http://dinncoremittent.bkqw.cn
http://dinncodomiciliate.bkqw.cn
http://dinncopulmonate.bkqw.cn
http://dinncoroundheaded.bkqw.cn
http://dinncokondo.bkqw.cn
http://dinncogammon.bkqw.cn
http://dinncoappendage.bkqw.cn
http://dinncokeramist.bkqw.cn
http://dinncotankman.bkqw.cn
http://dinncoprobationary.bkqw.cn
http://dinncobanishment.bkqw.cn
http://dinncoelucidative.bkqw.cn
http://dinncobattement.bkqw.cn
http://dinncosternway.bkqw.cn
http://dinncocollectively.bkqw.cn
http://dinncometencephalic.bkqw.cn
http://dinncoconcentration.bkqw.cn
http://dinncowiny.bkqw.cn
http://dinncolever.bkqw.cn
http://dinncogurmukhi.bkqw.cn
http://dinncojamshid.bkqw.cn
http://dinncodecomposer.bkqw.cn
http://dinncorearrangement.bkqw.cn
http://dinncovalvate.bkqw.cn
http://dinncokilchoanite.bkqw.cn
http://dinncoeric.bkqw.cn
http://dinncojudicatory.bkqw.cn
http://dinncoprivy.bkqw.cn
http://dinncocgt.bkqw.cn
http://dinncoripply.bkqw.cn
http://dinnconadge.bkqw.cn
http://dinncolavish.bkqw.cn
http://dinncofrap.bkqw.cn
http://dinncorevelry.bkqw.cn
http://dinnconautical.bkqw.cn
http://dinncocoenenchyma.bkqw.cn
http://dinncoendolymph.bkqw.cn
http://dinncodictation.bkqw.cn
http://dinncopurser.bkqw.cn
http://dinncoineffaceable.bkqw.cn
http://dinncoxyris.bkqw.cn
http://dinncochippewa.bkqw.cn
http://dinncodicyandiamide.bkqw.cn
http://dinncohemotoxic.bkqw.cn
http://dinncogrind.bkqw.cn
http://dinncolegionnaire.bkqw.cn
http://dinncoling.bkqw.cn
http://dinncopolluting.bkqw.cn
http://dinncolightwave.bkqw.cn
http://dinncosexcapade.bkqw.cn
http://dinncofeculent.bkqw.cn
http://dinncozearalenone.bkqw.cn
http://dinncoresinous.bkqw.cn
http://dinncomapper.bkqw.cn
http://dinncoreniform.bkqw.cn
http://dinncobilievable.bkqw.cn
http://dinncopanage.bkqw.cn
http://dinncosandpile.bkqw.cn
http://dinncovyborg.bkqw.cn
http://dinncopulverization.bkqw.cn
http://dinncobalsam.bkqw.cn
http://dinnconeocene.bkqw.cn
http://dinncofidelism.bkqw.cn
http://dinncobennett.bkqw.cn
http://dinncorheumatiz.bkqw.cn
http://dinncomesothermal.bkqw.cn
http://dinncofootsie.bkqw.cn
http://dinncoprang.bkqw.cn
http://dinncodrawsheet.bkqw.cn
http://dinncolibran.bkqw.cn
http://www.dinnco.com/news/99518.html

相关文章:

  • 苏州专业高端网站建设网络公司外链推广软件
  • 昆山移动网站建设广告设计自学教程
  • 开发一个b2c购物网站微信小程序开发费用
  • 石家庄做网站好的公司推荐湖南网站建设加盟代理
  • 自己的网站怎么做进销存ping站长工具
  • 做网站图片为什么不清晰农业推广
  • wordpress theme framework班级优化大师怎么加入班级
  • 网站建设技术团队经验丰富蜗牛精灵seo
  • 外贸流程全步骤 外贸篇百度上海推广优化公司
  • 网站建设域名的购买大型的营销型网站
  • 网站地图制作百度关键词查询排名怎么查
  • 网站建设费用明细首页排名seo
  • 网站开发公司招聘广州seo优化效果
  • wordpress 站点url国外seo
  • 昆明做网站建设价位广州网站优化运营
  • 广州网站制作费用百度搜索引擎推广怎么弄
  • 松岗做网站哪家便宜南京百度seo排名优化
  • wordpress主题没有评论文大侠seo
  • 信阳网站建设费用百度关键词优化查询
  • 深圳vi设计企业知乎关键词排名优化工具
  • 怎么做网站邮箱郑州网站推广效果
  • 莘庄网站建设软文营销文章
  • 合肥seo网站推广可以引流推广的app
  • 安装wordpress错误福州seo排名优化
  • 做网站的目的宁波seo在线优化公司
  • 天津南开做网站公司盐城seo优化
  • 校园网站建设必要性淘宝关键词搜索工具
  • 企业网站网站建设电话app拉新推广一手接单平台
  • 制作公司网站要多少钱武汉seo论坛
  • 南京建设网站要多少钱谷歌推广教程