当前位置: 首页 > wzjs >正文 简单网一键优化 wzjs 2025/8/3 0:13:33 简单网,一键优化,网站的用户体验,a3电子报在什么网站做错误解法一:正序查找的过程中,将前面的元素倒叙插入inverse链中,找到偶数中点时,对称查找。 /*** Definition for singly-linked list.* public class ListNode {* int val;* ListNode next;* ListNode() {}* Li…错误解法一:正序查找的过程中,将前面的元素倒叙插入inverse链中,找到偶数中点时,对称查找。 /*** 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 boolean isPalindrome(ListNode head) {if(head.next == null){// 只有一个元素return true;}ListNode inverse=null, find=head;while(find != null){// 把find倒叙插入inverse中ListNode temp=find.next;find.next = inverse;inverse = find;find = temp;while(find != null && inverse != null && find.val == inverse.val){// 找到中点在find和find.next之间find = find.next;inverse = inverse.next;}}if(find==null && inverse==null ){return true;}return false;} } 错误原因:没有考虑奇数情况 解法一:将数据转存到列表中,用双指针比较。 /*** 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 boolean isPalindrome(ListNode head) {List<Integer> list = new ArrayList<>();// 将所有数据放入list中while(head!=null){list.add(head.val);head=head.next;}// 使用左右指针查找int left=0,right=list.size()-1;while(left<right){if(list.get(left)!=list.get(right)){return false;}right--;left++;}return true;} } 查看全文 http://www.dtcms.com/wzjs/196170.html 相关文章: diango是做网站的后端吗营销策略怎么写模板 青岛网站专业制作今日资讯最新消息 如何做微信小程序?百度首页排名优化平台 山西网络科技有限公司网站优化检测工具 加强人社网站建设一站式营销推广 营销型网站有意义吗搜索引擎优化结果 wp网站怎么用插件做html网页百度推广账户优化方案 做时时彩网站费用网站怎么被百度收录 项目计划书范文免费aso优化师主要是干嘛的 高效网站建设与维护岗位职责国内重大新闻十条 中文网址的作用智能网站排名优化 做电商网站费用产品互联网营销推广 建设一个视频网站需要什么时候开始如何免费做网站推广的 天津网站建设教程电商运营公司排名 芜湖手机网站制作新泰网站seo 厦门做网站多少钱网络推广渠道排名 石材网站建设独立站seo推广 30天网站建设 视频教程百度智能建站系统 微信公众号推广运营广州网站seo公司 阿克苏网站建设咨询国外推广网站 济宁高端网站建设百度推广效果 做网站广告公司联系方式百度小说免费阅读 网站上传wordpress百度官网首页入口 做企业网站代码那种好免费手机网站自助建站 公司网站建设价格表免费网站安全软件大全 做公司官方网站关键词排名查询软件 网站建好怎么发布网站查询工具seo 日报做的地方网站宁波网站推广找哪家公司 肇庆网站开发哪家专业厦门seo公司 企业如何在工商网站上做公示百度企业查询
错误解法一:正序查找的过程中,将前面的元素倒叙插入inverse链中,找到偶数中点时,对称查找。 /*** 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 boolean isPalindrome(ListNode head) {if(head.next == null){// 只有一个元素return true;}ListNode inverse=null, find=head;while(find != null){// 把find倒叙插入inverse中ListNode temp=find.next;find.next = inverse;inverse = find;find = temp;while(find != null && inverse != null && find.val == inverse.val){// 找到中点在find和find.next之间find = find.next;inverse = inverse.next;}}if(find==null && inverse==null ){return true;}return false;} } 错误原因:没有考虑奇数情况 解法一:将数据转存到列表中,用双指针比较。 /*** 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 boolean isPalindrome(ListNode head) {List<Integer> list = new ArrayList<>();// 将所有数据放入list中while(head!=null){list.add(head.val);head=head.next;}// 使用左右指针查找int left=0,right=list.size()-1;while(left<right){if(list.get(left)!=list.get(right)){return false;}right--;left++;}return true;} } 查看全文 http://www.dtcms.com/wzjs/196170.html 相关文章: diango是做网站的后端吗营销策略怎么写模板 青岛网站专业制作今日资讯最新消息 如何做微信小程序?百度首页排名优化平台 山西网络科技有限公司网站优化检测工具 加强人社网站建设一站式营销推广 营销型网站有意义吗搜索引擎优化结果 wp网站怎么用插件做html网页百度推广账户优化方案 做时时彩网站费用网站怎么被百度收录 项目计划书范文免费aso优化师主要是干嘛的 高效网站建设与维护岗位职责国内重大新闻十条 中文网址的作用智能网站排名优化 做电商网站费用产品互联网营销推广 建设一个视频网站需要什么时候开始如何免费做网站推广的 天津网站建设教程电商运营公司排名 芜湖手机网站制作新泰网站seo 厦门做网站多少钱网络推广渠道排名 石材网站建设独立站seo推广 30天网站建设 视频教程百度智能建站系统 微信公众号推广运营广州网站seo公司 阿克苏网站建设咨询国外推广网站 济宁高端网站建设百度推广效果 做网站广告公司联系方式百度小说免费阅读 网站上传wordpress百度官网首页入口 做企业网站代码那种好免费手机网站自助建站 公司网站建设价格表免费网站安全软件大全 做公司官方网站关键词排名查询软件 网站建好怎么发布网站查询工具seo 日报做的地方网站宁波网站推广找哪家公司 肇庆网站开发哪家专业厦门seo公司 企业如何在工商网站上做公示百度企业查询