Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions problems/0024.两两交换链表中的节点.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,21 @@ var swapPairs = function (head) {
};
```

```javascript
// 递归版本
var swapPairs = function (head) {
if (head == null || head.next == null) {
return head;
}

let after = head.next;
head.next = swapPairs(after.next);
after.next = head;

return after;
};
```

### TypeScript:

```typescript
Expand Down