1 Star 0 Fork 0

Luigi / algorithm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
剑指offer书-16-翻转链表 615 Bytes
一键复制 编辑 原始数据 按行查看 历史
Luigi 提交于 2021-05-12 08:10 . add 剑指offer书-16-翻转链表.
/*
struct ListNode {
int val;
struct ListNode *next;
ListNode(int x) :
val(x), next(NULL) {
}
};*/
class Solution {
public:
ListNode* ReverseList(ListNode* pHead) {
ListNode* pReversdHead = NULL;
ListNode* pNode = pHead;
ListNode* pPrev = NULL;
while(pNode != NULL){
ListNode* pNext = pNode->next;
if(pNext != NULL){
pReversdHead = pNode;
}
pNode->next = pPrev;
pPrev = pNode;
pNode = pNext;
}
return pPrev;
}
};
1
https://gitee.com/muten/algorithm.git
git@gitee.com:muten/algorithm.git
muten
algorithm
algorithm
master

搜索帮助