两两交换链表中的节点

LeetCode Hot 100 链表
难度: 中等

题目描述

交换链表中每两个相邻的节点。

解题思路

使用递归或迭代方法,每次交换当前节点和后一个节点。时间复杂度为 O(n)。