当前位置:网站首页>BM13 determines whether a linked list is a palindrome
BM13 determines whether a linked list is a palindrome
2022-08-10 22:29:00 【dry rice white】

There are many solutions to this water problem:
I wrote it directly with the stack, so I won't explain the idea too much
There are only a few lines of code in total, and you can understand it with your eyes closed
Optimizable memory: only push the general stack, anyway, I don't think it is necessary to do so, if the topic has memory constraints, it can be optimized
/*** struct ListNode {* int val;* struct ListNode *next;* };*/class Solution {public:/**** @param head ListNode class the head* @return bool boolean*/bool isPail(ListNode* head) {// write code here//Write okk directly on the stackstacksta;ListNode *p = head;while(p != nullptr){sta.push(p->val);p = p->next;}p = head;while(p != nullptr){if(p->val != sta.top()){break;}sta.pop();p = p->next;}if(p == nullptr){return true;}return false;}}; 边栏推荐
- BM7 链表中环的入口结点
- 高通平台开发系列讲解(应用篇)QCMAP应用框架介绍
- 从斐波那契 - 谈及动态规划 - 优化
- shell编程之正则表达式与文本处理器
- Interpretation of the paper (g-U-Nets) "Graph U-Nets"
- Regular expression of shell programming and text processor
- 财务年报怎样翻译,为什么要选择专业翻译公司?
- [SQL brush questions] Day3----Special exercises for common functions that SQL must know
- 2022年8月10日:使用 ASP.NET Core 为初学者构建 Web 应用程序--使用 ASP.NET Core 创建 Web UI(没看懂需要再看一遍)
- win系统下pytorch深度学习环境安装
猜你喜欢

文件IO-缓冲区

unusual understanding

RADIUS Authentication Server Deployment Costs That Administrators Must Know

ThreadLocal comprehensive analysis (1)

Exploration and practice of the "zero trust" protection and data security governance system of the ransomware virus of Meichuang Technology

RK3399平台开发系列讲解(内核驱动外设篇)6.35、IAM20680陀螺仪介绍

H3C S5130 IRF做堆叠

xshell (sed command)

C#【必备技能篇】Hex文件转bin文件的代码实现

虚拟地址空间
随机推荐
Likou 215 questions, the Kth largest element in an array
水果沙拉酱
Play RT-THREAD of doxygen
2022年8月的10篇论文推荐
QT笔记——vs + qt 创建一个带界面的 dll 和 调用带界面的dll
力扣215题,数组中的第K个最大元素
从斐波那契 - 谈及动态规划 - 优化
BM7 链表中环的入口结点
[Maui official version] Create a cross-platform Maui program, as well as the implementation and demonstration of dependency injection and MVVM two-way binding
测试4年感觉和1、2年时没什么不同?这和应届生有什么区别?
自组织是管理者和成员的双向奔赴
What is Jmeter? What are the principle steps used by Jmeter?
uni-app微信小程序——下拉多选框
Using SylixOS virtual serial port, serial port free implementation system
异常的了解
TCP连接过程中如果拔掉网线会发生什么?
Black cat takes you to learn Makefile Part 11: When the header file a.h changes, how to recompile all the .c files that depend on the header file a.h
【SQL刷题】Day3----SQL必会的常用函数专项练习
unusual understanding
美味的佳肴