美文网首页
23、交换链表相邻结点

23、交换链表相邻结点

作者: BeijingIamback | 来源:发表于2016-03-25 19:52 被阅读16次

    Given a linked list, swap every two adjacent nodes and return its head.

    For example,

    Given 1->2->3->4, you should return the list as 2->1->4->3.

    Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed.

    参考代码

    相关文章

      网友评论

          本文标题:23、交换链表相邻结点

          本文链接:https://www.haomeiwen.com/subject/kgkdlttx.html