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

专业网站优化服务百度推广竞价是什么意思

专业网站优化服务,百度推广竞价是什么意思,全包装修公司哪家好点,百度网站 v怎么怎做提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言一、力扣876. 链表的中间结点二、力扣142. 环形链表 II三、力扣160. 相交链表四、力扣141. 环形链表 前言 一、力扣876. 链表的中间结点 /*** Definition for …

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

  • 前言
  • 一、力扣876. 链表的中间结点
  • 二、力扣142. 环形链表 II
  • 三、力扣160. 相交链表
  • 四、力扣141. 环形链表


前言


一、力扣876. 链表的中间结点

/*** 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 ListNode middleNode(ListNode head) {ListNode res = new ListNode(-1,head);ListNode p = head;int len = 0;while(p != null){p = p.next;len ++;}int i = len / 2 + 1;p = head;for(int j = 1; j < i; j ++){p = p.next;}return p;}
}

快慢指针遍历一次

/*** 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 ListNode middleNode(ListNode head) {ListNode dump = new ListNode(-1,head);ListNode p1 = dump, p2 = dump;for(; p2 != null;){p1 = p1.next;p2 = p2.next;if(p2 == null){return p1;}p2 = p2.next;}return p1;}
}

二、力扣142. 环形链表 II

/*** Definition for singly-linked list.* class ListNode {*     int val;*     ListNode next;*     ListNode(int x) {*         val = x;*         next = null;*     }* }*/
public class Solution {public ListNode detectCycle(ListNode head) {ListNode p1 = head, p2 = head;while(p1 != null && p2 != null && p2.next != null){p1 = p1.next;p2 = p2.next.next;if(p1 == p2){p1 = head;while(p1 != p2){p1 = p1.next;p2 = p2.next;}return p1;}}return null;}
}

三、力扣160. 相交链表

/*** Definition for singly-linked list.* public class ListNode {*     int val;*     ListNode next;*     ListNode(int x) {*         val = x;*         next = null;*     }* }*/
public class Solution {public ListNode getIntersectionNode(ListNode headA, ListNode headB) {ListNode p1 = headA, p2 = headB;int len1 = 0, len2 = 0;while(p1 != null){len1 ++;p1 = p1.next;}while(p2 != null){len2 ++;p2 = p2.next;}ListNode fast, slow;int edge = 0;if(len1 > len2){edge = len1 - len2;fast = headA;slow = headB;}else{edge = len2 - len1;fast = headB;slow = headA;}while(edge > 0){edge --;fast = fast.next;}while(fast != null && slow != null){if(fast == slow){return fast;}fast = fast.next;slow = slow.next;}return null;}
}

双指针

/*** Definition for singly-linked list.* public class ListNode {*     int val;*     ListNode next;*     ListNode(int x) {*         val = x;*         next = null;*     }* }*/
public class Solution {public ListNode getIntersectionNode(ListNode headA, ListNode headB) {ListNode p1 = headA, p2 = headB;while(p1 != p2){if(p1 == null) p1 = headB;else p1 = p1.next;if(p2 == null) p2 = headA;else p2 = p2.next;}return p1;}
}

四、力扣141. 环形链表

/*** Definition for singly-linked list.* class ListNode {*     int val;*     ListNode next;*     ListNode(int x) {*         val = x;*         next = null;*     }* }*/
public class Solution {public boolean hasCycle(ListNode head) {ListNode p1 = head, p2 = head;while(p1 != null && p2 != null  && p2.next != null){p1 = p1.next;p2 = p2.next.next;if(p1 == p2){return true;}}return false;}
}
http://www.hrbkazy.com/news/50226.html

相关文章:

  • 网站 做百度推广有没有效果百度搜索资源平台token
  • 美国企业黄页网站产品的网络推广要点
  • 网站顶部伸缩广告南阳网站seo
  • 淘宝开放平台怎么做淘宝客网站b站广告投放平台入口
  • 电子商务网站建设新手佛山网络公司 乐云seo
  • 企业百度网站怎么做如何网络媒体推广
  • wordpress修改固定链接重定向广东seo加盟
  • 城市分站cms网站推广软件免费版大全
  • 要建网站游戏推广怎么做
  • 在线ppt网站大数据营销案例
  • 谷歌推广网站建设营销培训心得体会
  • php 网站部署企业邮箱登录入口
  • php做网站还是linux长沙网络营销学校
  • 做动画 的 网站有哪些软件下载东莞关键词seo
  • 网络商城网站建设seo快速推广窍门大公开
  • 网站建设算什么专业今日的最新新闻
  • 西安市城乡建设委员会网站6外贸营销型网站制作
  • 关于做代购网站的纳税知识百度关键词优化
  • 给私人企业做网站推广yahoo搜索
  • 高端企业网站建站程序免费永久个人域名注册
  • 创新的龙岗网站建设网站建站哪家公司好
  • 网站开发工程师月薪网站开发从入门到实战
  • 邯郸有建网站吗哪个公司好些如何在百度发布广告信息
  • 房产网站开发文档推广一个产品有哪些方式
  • 做游戏ppt下载网站有哪些无锡seo公司哪家好
  • 郑州汉狮做网站的大公司2024年新闻摘抄十条
  • 专业公司做网站怎么做网站宣传
  • 山西省网站建设价格新产品推广策划方案
  • 客户评价 网站建设亚马逊seo什么意思
  • 打电话拉客户用网站做广告怎么做 好做吗广告公司简介