当前位置:网站首页>Determine whether the linked list is a palindrome linked list
Determine whether the linked list is a palindrome linked list
2022-07-01 16:47:00 【Fried tomatoes with duck eggs】
The first step is to put the values of the linked list in the array list , Then through the double pointer to determine whether it is a palindrome linked list , A pointer starts from scratch , The other pointer starts at the end , Traverse in turn , If the values encountered are different, return directly false, If the value is the same, continue to traverse , Until the two indexes meet .
First step :
List<Integer> arr=new ArrayList<Integer>();
ListNode currentNode=head;
Boolean flag=true;
while (currentNode!=null){
arr.add(currentNode.val);
currentNode=currentNode.next;
}The second step :
int front=0;
int back=arr.size()-1;
while (front<back){
if (!arr.get(front).equals(arr.get(back))){
flag=false;
}
front++;
back--;
}
return flag;边栏推荐
- 你还在用收费的文档管理工具?我这有更牛逼的选择!完全免费
- Red team Chapter 10: ColdFusion the difficult process of deserializing WAF to exp to get the target
- Preliminary study on golang crawler framework
- Origin2018安装与使用(整理中)
- sql刷题584. 寻找用户推荐人
- Germany if was crowned with many awards. How strong is this pair of headphones? In depth evaluation of yinpo GTW 270 hybrid
- 全面看待企业数字化转型的价值
- 数据库系统原理与应用教程(005)—— yum 离线安装 MySQL5.7(Linux 环境)
- 红队第10篇:coldfusion反序列化过waf改exp拿靶标的艰难过程
- 广东用电量大跌,说明高新技术产业替代高能耗产业已取得初步成果
猜你喜欢

Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers

免费抽奖 | 《阿巴豆》探索未来系列盲盒数字版权作品全网首发!

数据库系统原理与应用教程(006)—— 编译安装 MySQL5.7(Linux 环境)

PostgreSQL 存储结构浅析

为国产数据库添砖加瓦,StoneDB 一体化实时 HTAP 数据库正式开源!

Bugku's file contains
![[observation] where is the consulting going in the digital age? Thoughts and actions of softcom consulting](/img/82/3bb382893682a30e8af130365ec4ef.jpg)
[observation] where is the consulting going in the digital age? Thoughts and actions of softcom consulting

Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!

String类

模板引擎Velocity 基础
随机推荐
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
VMware 虛擬機啟動時出現故障:VMware Workstation 與 Hyper-v 不兼容...
博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
SystemVerilog-结构体(二)
UML tourism management system "suggestions collection"
判断二叉树是否为二叉搜索树
Leetcode 77 combination -- backtracking method
Tutorial on the principle and application of database system (005) -- Yum offline installation of MySQL 5.7 (Linux Environment)
P2592 [zjoi2008] birthday party (DP)
Basic use of MySQL
C語言輸入/輸出流和文件操作
软件工程导论——第六章——详细设计
Template engine velocity Foundation
Principes et applications du système de base de données (006) - - compilation et installation de MySQL 5.7 (environnement Linux)
Research and investment strategy report of China's sodium sulfate industry (2022 Edition)
FPN network details
Introduction to software engineering - Chapter 6 - detailed design
[nodemon] app crashed - waiting for file changes before starting...解决方法
Comprehensively view the value of enterprise digital transformation
虚拟串口模拟器和串口调试助手使用教程「建议收藏」