当前位置:网站首页>Reverse linked list
Reverse linked list
2022-06-12 05:29:00 【cbdgz】
Punch in one question every day
2020.12.20
Enter a linked list , After reversing the list , Output the header of the new linked list .
Their thinking :
In fact, it is a stack like method , Press each point of the original list into the new list like a stack ( For the convenience of understanding, I said the new linked list , But it doesn't actually create a new linked list ).
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/
class Solution {
public:
ListNode* ReverseList(ListNode* pHead) {
ListNode *ansLink=NULL;
ListNode *cur=pHead;
ListNode *nex=NULL;
while(NULL!=cur)
{
nex=cur->next;
cur->next=ansLink;
ansLink=cur;
cur=nex;
}
return ansLink;
}
};
边栏推荐
- Stm32f4 ll library multi-channel ADC
- The server time zone value ‘Ö Ð¹ ú±ê ×¼ ʱ ¼ ä‘ is unrecognized or represents more than one time zone. You
- JS set the position of the current scroll bar
- Yolov5 realizes road crack detection
- Nature | 给全球的新冠伤亡算一笔账
- CentOS compiling and installing mysql8.0
- Sv806 QT UI development
- Test work summary - performance test related issues
- 公司注册认缴资金多久
- JS disable mobile sharing
猜你喜欢

Is the individual industrial and commercial door a legal person enterprise

Detailed analysis of the 2021 central China Cup Title A (color selection of mosaic tiles)

Quickly get PCA (principal component analysis) (principle code case)

Introduction to audio alsa architecture

Pupanvr- an open source embedded NVR system (1)

yolov5

Selenium crawler automatically captures TOEFL test position of NEEA website
![[cjson] precautions for root node](/img/6c/4462bc8126935f00a5c64f18de13ea.png)
[cjson] precautions for root node

Introduction to MMS memory optimization of Hisilicon MPP service

How to quickly reference uview UL in uniapp, and introduce and use uviewui in uni app
随机推荐
Design of a simple embedded web service application
CODIS long link test
JS set the position of the current scroll bar
Test work summary - performance test related issues
Lesson 5: data warehouse construction (III)
Introduction to redis cluster
4.3 模拟浏览器操作和页面等待(显示等待和隐式等待、句柄)
JS how to get the date
Towards End-to-End Lane Detection: an Instance SegmentationApproach
Force/release learning and sorting in IC Verification (6) research on the influence of wire type signals
It costs less than 30 yuan, but we still don't build it quickly - check the small knowledge of software application
PHP实现图片登录验证码的解决方案
How to count the total length of roads in the region and draw data histogram
20. string representing numeric value
Performance & interface test tool - JMeter
分公司负责人需要承担的法律责任
Alsa architecture application aplay and amixer call relationship (from application layer to kernel driver)
Main business objects of pupanvr record (5)
ESP8266 Arduino OLED
WiFi smartconfig implementation