当前位置:网站首页>[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 .
边栏推荐
- Flutter System Architecture(Flutter系统架构图)
- Introduction of neural network (BP) in Intelligent Computing
- 百家讲坛 大秦崛起(下部)
- 53页智慧校园智能化系统设计方案(附下载)
- Huawei cloud releases Latin American Internet strategy
- 苹果Objective-C源代码
- R language universalbank CSV "data analysis
- 华为云发布拉美互联网战略
- Moke 6. Load balancing ribbon
- Using qtest for data set test performance test GUI test
猜你喜欢

Ultrafast transformers | redesign vit with res2net idea and dynamic kernel size, surpassing mobilevit

2022团体程序设计天梯赛L1

【876. 链表的中间结点】

让知识付费系统视频支持M3U8格式播放的方法

what? You can't be separated by wechat

Container container runtime (2): which is better for you, yum installation or binary installation?

迅睿CMS 自定义数据接口-php执行文件代码

Raspberry pie environment settings

R language usarrests dataset visualization

Résolu: peut - on avoir plus d'une colonne auto - incrémentale dans un tableau
随机推荐
R语言organdata 数据集可视化
Several common MySQL commands
Kotlin1.6.20 new features context receivers tips
百家讲坛 黄帝内经(第一部)
字节跳动提出轻量级高效新型网络MoCoViT,在分类、检测等CV任务上性能优于GhostNet、MobileNetV3!...
农产品期货开户
SwiftUI如何模拟视图发光增大的动画效果
84-我对网传<52 条 SQL 语句性能优化策略>的一些看法
MYSQL 几个常用命令使用
密码学系列之:PKI的证书格式表示X.509
A Dynamic Near-Optimal Algorithm for Online Linear Programming
88-被广为流传的参数优化, 是蜜糖还是毒药?
R language organdata dataset visualization
Moke 5. Service discovery -nacos
79-不要看到有order by xxx desc就创建desc降序索引-文末有赠书福利
CVPR 2022 oral | video text pre training new SOTA, HKU and Tencent arc lab launched excuse task based on multiple-choice questions
Can financial products be redeemed on weekends?
【876. 链表的中间结点】
启牛送的券商账户是安全的吗?启牛提供的券商账户是真的?
PlainSelect.getGroupBy()Lnet/sf/jsqlparser/statement/select/GroupByElement;
