1 Star 0 Fork 0

luobg01/PFJ_coding

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
code023_reverseList.h 591 Bytes
一键复制 编辑 原始数据 按行查看 历史
luobg01 提交于 2023-10-12 17:30 . 新增题目leetcode206:反转链表
//
// Created by 罗炳国 on 2023/10/11.
//
#ifndef PFJ_CODE023_REVERSELIST_H
#define PFJ_CODE023_REVERSELIST_H
#include "commonHeader.h"
/**
* leetcode 206题 反转链表: https://leetcode.cn/problems/reverse-linked-list/
* */
class code022_reverseList {
public:
ListNode* reverseList(ListNode* head) {
ListNode *pre = nullptr, *next = nullptr, *cur = head;
while (cur != nullptr) {
next = cur->next;
cur->next = pre;
pre = cur;
cur = next;
}
return pre;
}
};
#endif//PFJ_CODE023_REVERSELIST_H
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/luobg01/pfj_coding.git
git@gitee.com:luobg01/pfj_coding.git
luobg01
pfj_coding
PFJ_coding
master

搜索帮助