当前位置:网站首页>剑指 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;
}
};
边栏推荐
- Common dynamic memory errors
- BM setup process
- Thread - learning notes
- Pytorch distributed test pit summary
- Source code analysis of synergetics and ntyco
- Is it safe to open a stock account online?
- QT excel table read / write library - qtxlsx
- Install Kali extension 1: (kali resolution problem)
- Basic syntax and common commands of R language
- RDB and AOF persistence of redis
猜你喜欢

Data feature analysis skills - correlation test

Advertising effect cluster analysis (kmeans)

Image segmentation based on deep learning: network structure design

Qcodeeditor - QT based code editor

QT set process startup and self startup

Kali SSH Remote Login

MySQL field truncation principle and source code analysis

Source code analysis of synergetics and ntyco

Esp8266 building smart home system

Generic - learning notes
随机推荐
Go build reports an error missing go sum entry for module providing package ... to add:
0703 interface automation - MySQL database connection, encapsulation, adding database verification in use cases
Efficient pytorch: how to eliminate training bottlenecks
网上办理股票开户安全吗?
One question per day, a classic simulation question
JS capture, target, bubble phase
2. operator and expression multiple choice questions
Agent and classloader
Netlogo learning
5 connection modes of QT signal slot
Common dynamic memory errors
Basic syntax and common commands of R language
Single user mode
Source code analysis of zeromq lockless queue
Why do I need message idempotence?
Daily question, magic square simulation
Image segmentation based on deep learning: network structure design
JSON module dictionary and string conversion
3. Sequential structure multiple choice questions
Architecture evolution of high-performance servers -- Suggestions