当前位置:网站首页>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;
}
};
边栏推荐
- 2019 ZTE touyue · model compression scheme
- DCN (deep cross network) Trilogy
- WCF 入门教程二
- Examples of financial tasks: real-time and offline approval of three scenarios and five optimizations of Apache dolphin scheduler in Xinwang bank
- WCF 部署在IIS上
- IDEA快捷键
- 排序:归并排序和快速排序
- 3.0.0 alpha 重磅发布!九大新功能、全新 UI 解锁调度系统新能力
- NFT digital collection system development: what are the best digital marketing strategies for NFT digital collection
- The interface automation test with a monthly salary of 12k+ takes you to get started in 3 minutes
猜你喜欢

Machine learning related competition website

NFT数字藏品系统开发:数字藏品赋予品牌新活力

Hcip--- BGP comprehensive experiment

WCF introductory tutorial II

Uncover the mystery of cloud native data management: operation level

【推荐系统经典论文(十)】阿里SDM模型

在线问题反馈模块实战(十四):实现在线答疑功能

PXE efficient batch network installation

时间序列分析预测实战之ARIMA模型

Redis migrate tool migration error.
随机推荐
C # use log4net to record logs (basic chapter)
5. Multi table query
正则表达式规则以及常用的正则表达式
Learning Efficient Convolutional Networks Through Network Slimming
Compose canvas custom circular progress bar
MySQL installation tutorial - hands on installation
College degree sales career, from the third tier 4K to the first tier 20k+, I am very satisfied with myself
NFT digital collection system development: the collision of literature + Digital Collections
6. Combined data type
依赖和关联的对比和区别
NFT digital collection development: digital art collection enabling public welfare platform
Learn browser decoding from XSS payload
NFT数字藏品系统开发:华为发布首款珍藏版数字藏品
漂洋过海来看你
2021全球机器学习大会演讲稿
NFT digital collection system development: how enterprises develop their own digital collection platform
PXE高效批量网络装机
Regression analysis code implementation
Devaxpress.xtraeditors.datanavigator usage
OAuth2.0系列博客教程汇总