首页 > 其他 > 详细

[LintCode] Swap Two Nodes in Linked List 交换链表中的两个结点

时间:2016-05-15 00:20:53      阅读:245      评论:0      收藏:0      [点我收藏+]

 

Given a linked list and two values v1 and v2. Swap the two nodes in the linked list with values v1 and v2. It‘s guaranteed there is no duplicate values in the linked list. If v1 or v2 does not exist in the given linked list, do nothing.

Notice

You should swap the two nodes with values v1 and v2. Do not directly swap the values of the two nodes.

Example
Given 1->2->3->4->null and v1 = 2, v2 = 4.

Return 1->4->3->2->null.

 

[LintCode] Swap Two Nodes in Linked List 交换链表中的两个结点

原文:http://www.cnblogs.com/grandyang/p/5493999.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!