当前位置:网站首页>剑指 Offer 06. 从尾到头打印链表
剑指 Offer 06. 从尾到头打印链表
2022-06-25 15:32:00 【anieoo】

solution:
遍历一边链表,用数组保存节点值,最后reverse. 时间复杂度O(n)
class Solution {
public:
vector<int> reversePrint(ListNode* head) {
vector<int> res;
ListNode *cur = head;
while(cur != NULL) {
res.push_back(cur->val);
cur = cur->next;
}
reverse(res.begin(),res.end());
return res;
}
};
边栏推荐
- Solution of push code failure in idea
- Kali modify IP address
- Websocket (WS) cluster solution
- One question per day, punch in
- Several solutions to the distributed lock problem in partial Internet companies
- Using Visual Studio
- Std:: vector minutes
- Leetcode121 timing of buying and selling stocks
- Using R language in jupyter notebook
- 1090.Phone List
猜你喜欢

Record the time to read the file (the system cannot find the specified path)

(1) Introduction

basic_ String mind map

CV pre training model set

semget No space left on device

Design and implementation of timer

Data preprocessing - normalization and standardization

CPU over high diagnosis and troubleshooting
![[paper notes] overview of case segmentation](/img/93/57ad42e0c058b7d5fd1b4066678707.jpg)
[paper notes] overview of case segmentation

JS select all exercise
随机推荐
The robot is playing an old DOS based game
(translation) json-rpc 2.0 specification (Chinese version)
Using R language in jupyter notebook
Boost listening port server
在打新债开户证券安全吗,需要什么准备
Afterword of Parl intensive learning 7-day punch in camp
JMeter reading and writing excel requires jxl jar
JSON module dictionary and string conversion
Start using markdown
Summary of four parameter adjustment methods for machine learning
Joseph Ring - formula method (recursive formula)
55 specific ways to improve program design (2)
Image segmentation based on deep learning: network structure design
Learning to Measure Changes: Fully Convolutional Siamese Metric Networks for Scene Change Detection
Learning notes on February 8, 2022 (C language)
5 connection modes of QT signal slot
Detailed description of crontab command format and summary of common writing methods
System Verilog - thread
Why should the coroutine be set to non blocking IO
Basic knowledge of pointer