当前位置:网站首页>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;
}
};
边栏推荐
- NFT数字藏品系统开发:华为发布首款珍藏版数字藏品
- NFT数字藏品系统开发:文学+数字藏品的碰撞
- HCIP---MPLS详解和BGP路由过滤
- College degree sales career, from the third tier 4K to the first tier 20k+, I am very satisfied with myself
- NFT数字藏品开发:数字藏品与NFT的六大区别
- 此章节用于补充2
- 7月消息,Glassnode数据显示,Deribit上ETH永续期货合约未平仓头寸刚刚达到一个月高点237,959,827美元。
- C语言关键字extern
- PXE efficient batch network installation
- Regression analysis code implementation
猜你喜欢

Learn browser decoding from XSS payload

配置Flask

Examples of financial tasks: real-time and offline approval of three scenarios and five optimizations of Apache dolphin scheduler in Xinwang bank

C# 使用Log4Net记录日志(基础篇)

HCIP---BGP综合实验

Redis migrate tool migration error.

ARIMA model for time series analysis and prediction

Compose canvas custom circular progress bar

3.0.0 alpha blockbuster release! Nine new functions and new UI unlock new capabilities of dispatching system

时间序列分析预测实战之ARIMA模型
随机推荐
[daily question 1] 919. Complete binary tree inserter
OAuth2.0系列博客教程汇总
ModuleNotFoundError: No module named ‘pip‘解决办法
漂洋过海来看你
Download and install the free version of typora
Comparison and difference between dependence and Association
Network trimming: a data driven neuron pruning approach towards efficient deep architectures paper translation / Notes
Regular expression rules and common regular expressions
Taishan Office Technology Lecture: page width, height, size and source, and the conversion relationship between inches, centimeters and DPI
dcn(deep cross network)三部曲
Redis migrate tool migration error.
Simulation of transfer function step response output of botu PLC first-order lag system (SCL)
Regression analysis code implementation
配置Flask
NFT数字藏品系统开发:企业如何开发属于自己的数藏平台
NFT digital collection development: digital art collection enabling public welfare platform
如何保证缓存和数据库的双写一致性?
Deep learning model deployment
keras学习之:获取神经网络中间层的输出结果
What is bloom filter in redis series?