当前位置:网站首页>Sword finger offer 06 Print linked list from end to end
Sword finger offer 06 Print linked list from end to end
2022-06-11 08:55:00 【Drag is me】
leetcode Force button to brush questions and punch in
subject : The finger of the sword Offer 06. Print linked list from end to end
describe : Enter the head node of a linked list , Return the value of each node from the end to the end ( Return with array ).
Their thinking
1、 Traversing the linked list , Store the value of each linked list node in the array , And then use reverse Function invert array ;
Source code ##
class Solution {
public:
vector<int> reversePrint(ListNode* head) {
vector<int>v;
while (head) {
v.emplace_back(head->val);
head = head->next;
}
reverse(v.begin(), v.end());
return v;
}
};
边栏推荐
猜你喜欢

MySQL advanced features, you can read more about it and meet the interview

leetcode - 460. LFU 缓存

Matlab学习8-图像处理之线性与非线性锐化滤波、非线性平滑滤波

Sword finger offer 62 The last remaining number in the circle

Notes on MySQL core points

Introduction to knowledge atlas -- yedda annotation

ActiveMQ simple tutorial, suitable for beginners, learning notes yyds

处理RAW格式的图像,需要什么软件?

How to apply for BS 476-7 sample for display? Is it the same as the display

C language printing diamond
随机推荐
Textview text size auto fit and textview margin removal
vagrant 安装踩坑
剑指 Offer 51. 数组中的逆序对
Display DIN 4102-1 Class B1 fire test requirements
844. 比较含退格的字符串
leetcode - 230. The k-th smallest element in a binary search tree
2、 Rendering camera data
Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup
木板ISO 5660-1 热量释放速率摸底测试
Introduction to knowledge atlas -- yedda annotation
SAP abap内表分类与增删改查操作
窗帘做EN 1101易燃性测试过程是怎么样的?
剑指 Offer 06. 从尾到头打印链表
马志强:语音识别技术研究进展和应用落地分享丨RTC Dev Meetup
BS 7176软垫家具阻燃防火测试
K8S应用(四)—— 搭建redis5 集群(可供外部直接访问)
Matlab学习9-图像处理之非线性锐化滤波
M1 chip guide: M1, M1 pro, M1 Max and M1 ultra
M1 芯片指南:M1、M1 Pro、M1 Max 和 M1 Ultra
EN 45545 R24氧指数测试方法解析