当前位置:网站首页>[palindrome structure of or36 linked list]
[palindrome structure of or36 linked list]
2022-06-22 21:06:00 【Cat star people who love Durian】
List of articles
One 、 Title Description
Two 、 Provide easy to read code diagram

3、 ... and 、 Title code
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) {} };*/
struct ListNode *findMid(struct ListNode*head)
{
struct ListNode* fast=head;
struct ListNode* slow=head;
while(fast&&fast->next)
{
slow=slow->next;
fast=fast->next->next;
}
return slow;
}
struct ListNode * reserve(struct ListNode*head)
{
struct ListNode*newHead=NULL;
struct ListNode*cur=head;
while(cur)
{
struct ListNode*next=cur->next;
cur->next=newHead;
newHead=cur;
cur=next;
}
return newHead;
}
class PalindromeList {
public:
bool chkPalindrome(ListNode* A) {
ListNode* mid=findMid(A);
ListNode*head=reserve(mid);
ListNode*rhead=head;
ListNode*Ahead=A;
while(rhead&&Ahead)
{
if(rhead->val!=Ahead->val)
{
return false;
}
else
{
rhead=rhead->next;
Ahead=Ahead->next;
}
}
return true;
}
};
The above is the whole content of this article , If there are mistakes in the article or something you don't understand , Communicate more with meow bloggers . Learn from each other and make progress . If this article helps you , Can give meow bloggers a concern , Your support is my biggest motivation .
边栏推荐
- uniapp小程序商城开发thinkphp6积分商城、团购、秒杀 封装APP
- Scheduling with Testing
- The road to systematic construction of geek planet business monitoring and alarm system
- Stochastic Adaptive Dynamics of a Simple Market as a Non-Stationary Multi-Armed Bandit Problem
- R language airpassengers dataset visualization
- Stochastic Adaptive Dynamics of a Simple Market as a Non-Stationary Multi-Armed Bandit Problem
- SwiftUI如何模拟视图发光增大的动画效果
- 87-with as写法的5种用途
- 如何计算 R 中的基尼系数(附示例)
- PlainSelect.getGroupBy()Lnet/sf/jsqlparser/statement/select/GroupByElement;
猜你喜欢

R语言penguins数据集可视化

Visualization of R language nutrient dataset

Resolved: can there be multiple auto incrementing columns in a table

NumPy学习笔记(六)——sum()函数

R language Midwest dataset visualization
Gradle Build Cache引发的Task缓存编译问题

【513. 找树左下角的值】

采用网络远程访问树莓派。

R语言 co2数据集 可视化

Container container runtime (2): which is better for you, yum installation or binary installation?
随机推荐
R语言AirPassengers数据集可视化
NBA季后赛对阵图
[observation] innovation in the software industry has entered a "new cycle". How can we make a new start in the changing situation?
How to calculate the Gini coefficient in R (with examples)
【20. 有效的括号】
[Jianzhi offer] interview question 44 A digit in a sequence of numbers
底部菜单添加的链接无法跳转到二级页面的问题
R 语言 UniversalBank.csv“ 数据分析
苹果CoreFoundation源代码
Performance test (I)
[proteus simulation] 8x8LED dot matrix digital cyclic display
R language CO2 dataset visualization
Container container runtime (2): which is better for you, yum installation or binary installation?
laravel+宝塔计划任务
How to calculate yoy and mom in MySQL
Scheduling with Testing
MySQL advanced (II)
Resolved: can there be multiple auto incrementing columns in a table
云服务器中安装mysql(2022版)
[in depth understanding of tcapulusdb technology] form creation and approval of document acceptance
