翻转链表
ListNode* ReverseList(ListNode* head) {
ListNode* pre = nullptr;
ListNode* cur = head;
ListNode* next = nullptr;
while (cur)
{
next = cur->next;
cur->next = pre;
pre = cur;
cur = next;
}
return pre;
}
ListNode* pre = nullptr;
ListNode* cur = head;
ListNode* next = nullptr;
while (cur)
{
next = cur->next;
cur->next = pre;
pre = cur;
cur = next;
}
return pre;
}
全部评论
相关推荐
点赞 评论 收藏
分享
点赞 评论 收藏
分享
2025-11-29 23:52
青岛理工大学 数据运营 chahine:我原来跟你一样,没找到就焦虑的不行,刚找到的时候特别开心呢,现在上了几个月的班了,真想抽死当初傻乐的自己。。。
点赞 评论 收藏
分享
2025-12-19 21:53
门头沟学院 Java
想做OpenGL:不要一来就把自己定位这么低吧,把大厂当成目标,不断去学技术做项目,最后你至少能学到能找到中小厂的技术水平,你一上来就找这种两千块还要前后端都会的,其实对你用处不会很大,真去了也是打杂 点赞 评论 收藏
分享
点赞 评论 收藏
分享