当前位置:网站首页>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;
}
};
边栏推荐
- mysql高级特性篇,可以多看看,应付面试
- 面试官问了四个问题,总结了4个经验
- 补2:圆环回原点问题
- Matlab learning 9- nonlinear sharpening filter for image processing
- Screening frog log file analyzer Chinese version installation tutorial
- 处理RAW格式的图像,需要什么软件?
- M1 chip guide: M1, M1 pro, M1 Max and M1 ultra
- 命名实体识别之CRF的实现方式
- 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
- 【C语言-指针进阶】挖掘指针更深一层的知识
猜你喜欢

Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup

MySQL核心点笔记

Matlab learning 7- linear smoothing filtering of image processing

TextView文本大小自动适配与TextView边距的去除

【C语言-数据存储】数据在内存中是怎样存储的?

Iso8191 test is mentioned in as 3744.1. Are the two tests the same?

Introduction to knowledge atlas -- yedda annotation

MATLAB R2022a 安装教程

进程间的通信

Award winning survey | how Apache pulsar lived in 2022, you the final say
随机推荐
Using docker compose to build redis5 cluster
M1 chip guide: M1, M1 pro, M1 Max and M1 ultra
Not eligible for getting processed by all beanpostprocessors
[cvpr2022] intensive reading of querydet papers
E. X的放大与缩小(运算符重载)
Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup
c语言打印心形
leetcode - 518. 零钱兑换 II
MySQL核心点笔记
File system check of the root filesystem failed
c的printf相关
Award winning survey | how Apache pulsar lived in 2022, you the final say
使用express+mysql创建一个基于nodejs的后台服务
leetcode - 460. LFU cache
PVC plastic sheets BS 476-6 determination of flame propagation properties
leetcode - 518. Change II
Analysis of EN 45545 R24 oxygen index test method
What software is required to process raw format images?
复制的代码格式混乱怎么办?
【clickhouse专栏】新建库角色用户初始化