当前位置:网站首页>206. 反转链表
206. 反转链表
2022-06-11 08:55:00 【拽拽就是我】
leetcode力扣刷题打卡
题目:206. 反转链表
描述:给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。
解题思路
1、用数组;
2、用栈;
原代码##
class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode *dummy = new ListNode(-1);
ListNode *p = dummy;
stack<ListNode *>s;
while (head) {
s.push(head);
head = head->next;
}
while (!s.empty()) {
dummy->next = s.top();
dummy = dummy->next;
s.pop();
}
dummy->next = nullptr;
return p->next;
}
};
边栏推荐
- How to apply for ASTM E108 flame retardant test for photovoltaic panels?
- c的printf相关
- PVC 塑料片BS 476-6 火焰传播性能测定
- leetcode - 460. LFU cache
- Zipkin入门
- 【C语言-指针进阶】挖掘指针更深一层的知识
- Interprocess communication
- EN 45545-2:2020 T11 smoke toxicity test
- 指定环境下安装Jupyter
- (1) AAC opening - lifecycle, livedata, ViewModel and source code analysis skills of core component principles (Reprint)
猜你喜欢

Redis6 entry-level tutorial. There are integration cases. You can directly see the integration cases. It is easy to get started

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

Zipkin入门

What software is required to process raw format images?

Classical graph theory, depth first and breadth first, topology, prim and krukal, it's time to review

The interviewer asked four questions and summed up four experiences

Matlab学习7-图像处理之线性平滑滤波

What is concurrent search set? Are you still worried about it? In fact, it is a problem of connected graph, which is not so difficult to understand

Heap can also be regarded as a tree structure. It is specified that the root node must be greater than or less than the left and right child nodes, but the size order of the left and right child nodes

B+ super tree helps you know the underlying structure of MySQL
随机推荐
Sword finger offer 10- ii Frog jumping on steps
leetcode - 230. The k-th smallest element in a binary search tree
光伏板怎么申请ASTM E108阻燃测试?
Which Apple devices support this system update? See if your old apple device supports the latest system
剑指 Offer 51. 数组中的逆序对
Analysis of EN 45545 R24 oxygen index test method
Heap can also be regarded as a tree structure. It is specified that the root node must be greater than or less than the left and right child nodes, but the size order of the left and right child nodes
一些学习记录i=
Livedata and stateflow, which should I use?
M1 芯片指南:M1、M1 Pro、M1 Max 和 M1 Ultra
【C语言-函数栈帧】从反汇编的角度,剖析函数调用全流程
木板ISO 5660-1 热量释放速率摸底测试
leetcode - 460. LFU 缓存
SAP abap内表分类与增删改查操作
【clickhouse专栏】新建库角色用户初始化
补2:圆环回原点问题
PHP解决中文显示乱码
【Image Processing】空间域图像增强
SAP 物料主数据归档
利用docker-compose搭建redis5集群