当前位置:网站首页>Sword finger offer 06 Print linked list from end to end
Sword finger offer 06 Print linked list from end to end
2022-06-25 15:36:00 【anieoo】
Original link : The finger of the sword Offer 06. Print linked list from end to end

solution:
Traverse side linked list , Save node values in an array , Last reverse. Time complexity 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;
}
};
边栏推荐
猜你喜欢

JMeter reading and writing excel requires jxl jar

Brief introduction to class loading process
![[paper notes] contextual transformer networks for visual recognition](/img/e4/45185983e28664564bbf79023ccbf6.jpg)
[paper notes] contextual transformer networks for visual recognition

Install Kali extension 1: (kali resolution problem)

Learning to Measure Changes: Fully Convolutional Siamese Metric Networks for Scene Change Detection

Day01: learning notes

If a thread overflows heap memory or stack memory, will other threads continue to work

Several common optimization methods

Esp8266 building smart home system

04. binary tree
随机推荐
0706-- replace fields in the use case, such as mobile phone number or ID
Bessie's weight problem [01 backpack]
How to deal with mining process
剑指 Offer 05. 替换空格
Common dynamic memory errors
CV pre training model set
The last glory of the late Ming Dynasty - the battle of Korea
(2) Relational database
Is it safe to open a stock account through the account opening link of the account manager?
Work of the first week
Could not connect to redis at 127.0.0.1:6379 in Windows
Why do I need message idempotence?
Advertising effect cluster analysis (kmeans)
Mining procedure processing
Markdown learning
Go language modifies / removes multiple line breaks in strings
RDB and AOF persistence of redis
剑指 Offer 04. 二维数组中的查找
google_ Breakpad crash detection
国信金太阳靠谱吗?是否合法?开股票账户安全吗?