当前位置:网站首页>Leetcode 206. reverse chain list (2022.07.25)
Leetcode 206. reverse chain list (2022.07.25)
2022-07-26 07:29:00 【ChaoYue_ miku】
Here's the head node of the list head , Please reverse the list , And return the inverted linked list .
Example 1:
Input :head = [1,2,3,4,5]
Output :[5,4,3,2,1]
Example 2:
Input :head = [1,2]
Output :[2,1]
Example 3:
Input :head = []
Output :[]
Tips :
The number range of nodes in the linked list is [0, 5000]
-5000 <= Node.val <= 5000
source : Power button (LeetCode)
Method 1 : iteration
C++ Submission :
class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode* prev = nullptr;
ListNode* curr = head;
while (curr) {
ListNode* next = curr->next;
curr->next = prev;
prev = curr;
curr = next;
}
return prev;
}
};
边栏推荐
- It's another summer of open source. 12000 project bonuses are waiting for you!
- Apache DolphinScheduler 2.X保姆级源码解析,中国移动工程师揭秘服务调度启动全流程
- [keras entry log (3)] sequential model and functional model in keras
- MySQL syntax (2) (pure syntax)
- The interface automation test with a monthly salary of 12k+ takes you to get started in 3 minutes
- Deep learning model deployment
- 4、数据的完整性
- WCF deployed on IIS
- Compose canvas custom circular progress bar
- 6. Backup and recovery of MySQL database
猜你喜欢

程序环境和预处理

PostgreSQL sequence create alter nextval Curval numerical interval gap

Installation of Baidu flying paste deep learning framework tutorial in Anaconda

NFT digital collection system development: the collision of literature + Digital Collections

7月消息,Glassnode数据显示,Deribit上ETH永续期货合约未平仓头寸刚刚达到一个月高点237,959,827美元。

NFT数字藏品系统开发:NFT数藏 的最佳数字营销策略有哪些

Simulation of transfer function step response output of botu PLC first-order lag system (SCL)

NFT digital collection system development: what are the best digital marketing strategies for NFT digital collection

pycharm常用快捷键

Deep learning model deployment
随机推荐
程序环境和预处理
“尝鲜”元宇宙,周杰伦最佳拍档方文山将于7月25日官宣《华流元宇宙》
NLP natural language processing - Introduction to machine learning and natural language processing (3)
Become an Apache contributor, so easy!
OVS底层实现原理
此章节用于补充
时间序列分析预测实战之ARIMA模型
C51 and MDK coexist keil5 installation tutorial
Next item recommendations in short sessions
Devaxpress.xtraeditors.datanavigator usage
Learning Efficient Convolutional Networks Through Network Slimming
ModuleNotFoundError: No module named ‘pip‘解决办法
With someone else's engine, can it be imitated?
Wrong Addition
NFT数字藏品系统开发:华为发布首款珍藏版数字藏品
Open source management system based on ThinkPHP
PostgreSQL UUID fuzzy search UUID string type conversion SQL error [42883] explicit type casts
MMOE multi-objective modeling
NFT数字藏品开发:数字藏品助力企业发展
MMOE多目标建模