#24

Swap Nodes in Pairs

medium · 69% accepted · 13,084 likes · top 76%

linked list · recursion

⊣ practice⊣ quiz⊣ open on leetcode ↗

Description

Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)

Solution