题解 | #反转链表#

反转链表

http://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca

/* struct ListNode { int val; struct ListNode next; ListNode(int x) : val(x), next(NULL) { } };/ class Solution { public: ListNode* ReverseList(ListNode* pHead) { ListNode* prehead = new ListNode(0); prehead->next = pHead ; ListNode* prenode = prehead ; ListNode* now = pHead ; ListNode* nex = pHead->next ; ListNode* temp = nullptr ; while( now) { now->next = temp ; temp = now; now = nex ; nex = nex->next ; } return temp ;

}

};

全部评论

相关推荐

这一集 硕士输的很惨
找工作ing10:就是这样不是硕士不愿意脱下长衫,是人家觉得屈才了
点赞 评论 收藏
分享
嵌入式求职之路:可以看我经验😂,https://www.nowcoder.com/share/jump/73221730841876945
点赞 评论 收藏
分享
05-12 22:16
已编辑
北京邮电大学 研发工程师
牛客302360988号:0offer+1 滴滴都不给我面 佬没投鹅吗,鹅应该很喜欢北邮吧
投递美团等公司7个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务