当前位置:网站首页>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 digital collection system development: digital collections give new vitality to brands
- NFT digital collection development: digital collections help enterprise development
- With someone else's engine, can it be imitated?
- hot100 哈希
- It's another summer of open source. 12000 project bonuses are waiting for you!
- In July, glassnode data showed that the open position of eth perpetual futures contract on deribit had just reached a one month high of $237959827.
- NFT数字藏品系统开发:企业如何开发属于自己的数藏平台
- Hcip--- MPLS detailed explanation and BGP route filtering
- [C language] do you really know printf? (printf is typically error prone, and collection is strongly recommended)
猜你喜欢

基于Thinkphp的开源管理系统

ARIMA model for time series analysis and prediction

China Unicom transformed the Apache dolphin scheduler resource center to realize the one-stop access of cross cluster call and data script of billing environment

HCIP---BGP综合实验

DADNN: Multi-Scene CTR Prediction via Domain-Aware Deep Neural Network

From boosting to lamdamart

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

In July, glassnode data showed that the open position of eth perpetual futures contract on deribit had just reached a one month high of $237959827.

KDD2022 | 揭秘快手短视频推荐Re-ranking之谜,相关推荐新SOTA

元宇宙基础设施:WEB 3.0 chain33 优势分析
随机推荐
This section is intended to supplement
Crawler data analysis
Compose text and icon splicing to realize drawableleft or drawableright
Model pruning 3: learning structured sparsity in deep neural networks
Unity3d asynchronous loading of scenes and progress bar loading
Taishan office lecture: word error about inconsistent values of page margins
QT: list box, table, tree control
Hcip--- BGP comprehensive experiment
Tensorflow learning diary tflearn
Redis系列之什么是布隆过滤器?
MySQL syntax (2) (pure syntax)
[classic thesis of recommendation system (10)] Alibaba SDM model
QT: modal, modeless, text box, button, single line input box
5、多表查询
Singles cup web WP
Moonbeam orbiters program: provides a new way for collectors to participate in moonbeam and Moonriver
Taishan Office Technology Lecture: how to calculate page blank (margin)
PXE高效批量网络装机
此章节用于补充2
Simulation of transfer function step response output of botu PLC first-order lag system (SCL)